• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exporting HTML-Table data to EXCEL sheet

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic