Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

How to export data in excel  RSS feed

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have data on jsp page and i want to export it on to excel.
 
Marshal
Posts: 64496
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure, but I believe Excel reads csv (comma-separated value) files. You would have to print to a text file with commas separating the values, and make sure you import into an Excel workbook with the same format.
 
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put a botton on the JSP page that causes the servlet (or another one) to generate a the data in a .csv file.

Or some other format that Excel likes. But csv is the easiest to do
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put the data in a text file (comma-separated value) then open the file with Excel, this is the easy way.
You can also call a servlet, iterate the list where you have the data and use the POI library (http://jakarta.apache.org/poi/), to bring the data in a file excel.
Another way is to use the library DisplayTag in your jsp, this is a tag that display the data in a table, give it a list of objects and it will handle column display, sorting, paging, cropping, grouping, exporting, smart linking and decoration of a table in a customizable XHTML style. Take a look to this url
http://displaytag.sourceforge.net/11/
http://displaytag.sourceforge.net/11/export.html
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming the user has excel or some other spreadsheet installed on your desktop you can set your servlet response as the following and the page will automatically be loaded into excel.

 
Tell me how it all turns out. Here is a tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!