File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes How to export data in excel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "How to export data in excel" Watch "How to export data in excel" New topic

How to export data in excel

SaurabhSri Sri
Ranch Hand

Joined: May 01, 2008
Posts: 43
I have data on jsp page and i want to export it on to excel.

SaurabhSri (SCJP 1.5)
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46362
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.
Pat Farrell

Joined: Aug 11, 2007
Posts: 4659

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
Luis Lopez Coronado

Joined: May 16, 2008
Posts: 6
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 (, 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
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 862
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. - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
It is sorta covered in the JavaRanch Style Guide.
subject: How to export data in excel
It's not a secret anymore!