Search code examples
exceljspapache-poiexport-to-excelpoi-hssf

How to export <table> content (which is inside a one <div >) into excel by JSP


I have developed a web application using JSP which creates a page with several page elements and a with multiple records. I wanted to export the content in that into an excel file.

I used the code

response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "inline; filename="
        + "excel.xls");

as described in this article http://www.quicklyjava.com/export-web-page-to-excel/

But it exports the whole page. How can a export only the content in that particular table?

I cannot use the Apache POI library since i have to format(text colors,cell colors) the content in the JSP. And i need the same formatting in the excel file.

Can somebody help me with this? :)


Solution

  • Haven't found a way to export only a single table in a page. But the intended task(create a excel sheet with formatted data) can be done by Apache POI HSSF library

    Here are the links to learn how to & examples - http://poi.apache.org/spreadsheet/how-to.html#user_api

    http://poi.apache.org/spreadsheet/examples.html