• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exporting HTML-Table data to EXCEL sheet

 
Harish Maridi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a JSP cantian, Header,footer and a HTML table which is dynamically generated from the previous page.
I am trying to export that HTML table data to a EXCEL sheet.

I placed the above code in my JSP. Its generating Excel sheet with Header, table, and Footer(but its not showing the result page).

But My application needs,
After displaying the result page(Result page cantains Header, Footer and HTML table) , I have a link "Export to Excel" .
Once I click that link it should generate a Excel sheet with only HTML Table contents.(Not with all)
Is there any speicfic way to do that. Please suggest me some way.

Thanks in advance,
-Mark
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cantian?

You can't mix the two responses in the same request. See this recent similar post.
 
Harish Maridi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP page only contains one HTML table with 6 columns, lets say (column1,2,3,4,5,6), I placed a hyperlink to column1 to show the deaials of that record(Table contains 100's of records).

I need to place a button at the bottom of the table "EXPORT TO EXCEL".
When I click that button, The data in the HTML Table(100's of records )should export to EXCEL sheet without reloding the page and user be able to save that excel sheet.

Once user saved the excel sheet, then if he wants to view the record details then he will click on the hyperlink(column 1) and view the details.

how to achieve this functionality EXPORT TO EXCEL with button?
Please suggest me.
-Mark
 
Rajeev Desh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,
You can have a jsp file that displays results along with a button
"export to excel" upon clicking this, call another jsp with appropriate html format(hope you would do that) that you want to show in excel sheet, say "export_to_excel.jsp".
"& lt;" input type='button' value='Export To Excel' "& lt;" on click="javascript:window.location.href='export_to_excel.jsp ""& lt;"

you can create a jsp file export_to_excel.jsp and set the response like:
response.setContentType("application/vnd.ms-excel");
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "max-age=0");

upon clicking the button, you will see a dialogue box asking to save or display ...
that will be self explainatory!

cheers....
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except, of course, that doesn't do anything to create an excel file -- it only tells the browser that the response should be such a file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic