Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8046429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:47:00+00:00 2026-06-05T05:47:00+00:00

I have a jsp page populated with tables from a data base. I have

  • 0

I have a jsp page populated with tables from a data base. I have to throw the data of this table in
excel file. Also I have to customize the excel file like border colors, fonts merging cell
cell colors
etc along with the data. How can I do it? Is there any java script for this
work? or are there any open source tools for this task?

I have found one like dataTables jquery package but it did not customize the excel file
only throws data to excel.
or do I have to use java libraries??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:47:02+00:00Added an answer on June 5, 2026 at 5:47 am

    You can use Apache POI for that.

    For Reference –

    public class xyzExcelExportView extends AbstractExcelView {
    
        private static final xyzService xyzService = ApplicationContextProvider.getxyzServiceImpl();
    
        @SuppressWarnings({ "unchecked" })
        protected void buildExcelDocument(Map model, HSSFWorkbook workbook,
                HttpServletRequest request, HttpServletResponse response)
                throws Exception {
            CurrencyService currencyService = ApplicationContextProvider.getCurrencyService();
            Currency currency = null;
            //set Response
            response.setContentType("application/vnd.ms-excel");
            response.setCharacterEncoding("UTF-8");
            response.setHeader("Content-Disposition", "Attachment;Filename=\""+"ExcelExport"+"."+"xls" + "\"");
            // Create Sheet.
            HSSFSheet sheet = workbook.createSheet("Software Contract Database");
            // Create Style for sheet.
            HSSFCellStyle headerStyle = workbook.createCellStyle();
            HSSFCellStyle dateStyle = workbook.createCellStyle();       
            HSSFCellStyle datePatternStyle = workbook.createCellStyle();
            HSSFDataFormat format1 = workbook.createDataFormat();
            HSSFCellStyle dataStyle = workbook.createCellStyle();
            HSSFCellStyle numberStyle = workbook.createCellStyle();     
            dateStyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
            dataStyle.setWrapText(true);
            datePatternStyle.setDataFormat(HSSFDataFormat
                    .getBuiltinFormat("d-mmm-yy"));
            numberStyle.setDataFormat(format1.getFormat("#,##0"));
            // Font setting for sheet.
            HSSFFont font = workbook.createFont();
            HSSFPalette palette = workbook.getCustomPalette();
            palette.setColorAtIndex(HSSFColor.LAVENDER.index,
                    (byte) 204,  
                    (byte) 204,    
                    (byte) 255);
            font.setBoldweight((short) 700);
            sheet.setDefaultColumnWidth((short) 30);
            List<Type> dataList = // YOur Data list     
            int currentRow = 0;
            // WRITE ROW FOR HEADER
            HSSFCell header = null;
            for (short i = 0; i < getHeader().size(); i++) {
                header = getCell(sheet, currentRow, i);
                headerStyle.setFillForegroundColor(HSSFColor.LAVENDER.index);
                headerStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
                headerStyle.setFont(font);
                header.setCellStyle(headerStyle);
                setText(header, getxyzHeader().get(i));
            }       
    
            HSSFRow row = null;
            HSSFCell cellNumber = null;
            HSSFCell cellString = null;
            HSSFCell cellNumberWitnComma = null;
            HSSFCell cellDate = null;
    
            for(Type xyz : dataList){
                    currentRow++;
                    short i = 0;
                    row = sheet.createRow(currentRow);
                    cellNumber = row.createCell(i);
                    cellNumber = fillxyzExcelExportCell(xyz.getId() == null ? 0 : xyz.getId(), 1 , cellNumber);
                    cellNumber.setCellStyle(dataStyle);
    
                    cellString = row.createCell(++i);
                    cellString = fillxyzExcelExportCell(xyz.getStatus() == null ? "" : xyz.getStatus() , 3 , cellString);   
                    cellString.setCellStyle(dataStyle); 
    
                    cellString = row.createCell(++i);
                    cellString = fillxyzExcelExportCell(xyz.getxyzStatus() , 3 , cellString);   
                    cellString.setCellStyle(dataStyle);
    
                    cellString = row.createCell(++i);
                    cellString = fillxyzExcelExportCell(xyz.getName() == null ? "" : xyz.getName(), 3 , cellString);
                    cellString.setCellStyle(dataStyle);     
                }
            }   
            workbook.write(response.getOutputStream());
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table on my jsp page that will have a column populated
I have jsp page which diplays a huge data in table format in the
I have a JSP page retrieving data and when single or double quotes are
I have a JSP page at an address like this: http://example.com/foo/bar/rawr/something.jsp When I output
I have a jsp page which needs a java code. This java code inside
I have a functional JSP page that accepts URL parameters and updates a table
I have a JSP page, from where onClick I want to execute a servlet
I have a jsp page in which there is a html table. The contents
I have jsp page and html form with button on this. How execute java
Have JSP page with dynamically generated HTML table with unknown number of rows. Have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.