0

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? :)

12
  • You can just move the table into a new page and set the content type to application/vnd.ms-excel in it. Commented Jan 19, 2013 at 13:22
  • see stackoverflow.com/questions/5524143/… Commented Jan 19, 2013 at 14:14
  • @Luiggi : I have to keep the other elements in the page. Cannot use a separate page with just the table. It's against the requirement. :( Commented Jan 19, 2013 at 17:59
  • You asked to export the table content into an Excel file, so you can use a button i.e. <input type="submit" value="Export to Excel" /> to call the page with the Excel content type and the table content, nothing else. In this way, your initial page keeps intact and your new page contains the same table/data. Commented Jan 19, 2013 at 18:27
  • @Rachel : I read that question but it doesn't have the answer for exporting only the content of a table. Commented Jan 19, 2013 at 18:31

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.