We need to use jsp/servlet as our tool to retrieve database and display the data table in 1) HTML format and 2) Excel spreadsheet file format.
I want to know how I can display the data table in Excel spreadsheet file format. Is it possible to create an output excel file to allow client download ? How ?
thanks, steve
Stephen Huey
Ranch Hand
Joined: Jul 15, 2003
Posts: 618
posted
0
The easiest way to get the downloaded data to load up in Microsoft Excel on Windows machines is to output it in simple delimited text, like a CSV file. Just copy the following into a text editor, save it as .csv, and Excel will probably open it by default, or if you load it into Excel, it will figure out that it's a comma-separated values file and display each field in its own cell:
So, pull your data out of the database, create a file out of it like the above, and give that to the user, and tell them to open it in Excel (although on Windows .csv files tend to open in Excel by default). From there, they could actually save it as a .xls file if they wanted to.
Narendra Dhande
Ranch Hand
Joined: Dec 04, 2004
Posts: 950
posted
0
Hello,
The CVS format is fine. I want to add little bit more. To generate a Excel format response, set the response header to "application/vnd.ms-excel" using response.setContentType("application/vnd.ms-excel"); and write all data in Tab deleimited format.
Depend on your Browser setting, the page will open with MS Excel or the browser ask to save the file or open it.
The CVS format is fine. I want to add little bit more. To generate a Excel format response, set the response header to "application/vnd.ms-excel" using response.setContentType("application/vnd.ms-excel"); and write all data in Tab deleimited format.
Depend on your Browser setting, the page will open with MS Excel or the browser ask to save the file or open it.
Thank you
Thanks. Could you tell me how to set browser to either open with MS Excel or the browser ask to save the file or open it ? (For IE and Netscape)
steve francisco
Ranch Hand
Joined: Jan 26, 2005
Posts: 46
posted
0
Originally posted by Narendra Dhande: Hello,
The CVS format is fine. I want to add little bit more. To generate a Excel format response, set the response header to "application/vnd.ms-excel" using response.setContentType("application/vnd.ms-excel"); and write all data in Tab deleimited format.
Depend on your Browser setting, the page will open with MS Excel or the browser ask to save the file or open it.
Thank you
what I prefer to do is --- After user clicks a "Get results" button, he will see a result page showing data in Excel format, and at the bottom of the page, there is small icon saying "download this file", and if he clicks it, he can download it as an Excel file. Is this doable ??
You would need to use frames. Frame 1 would have the button that just calls the same URL. If pressed the page is sent down as an attatchment instead of 'inline'.
Frame 2 would have the Excel page as an 'inline' page.
Originally posted by Ben Souther: You would need to use frames. Frame 1 would have the button that just calls the same URL. If pressed the page is sent down as an attatchment instead of 'inline'.
Frame 2 would have the Excel page as an 'inline' page.
when you say "inline" page, do you mean just let the browser display a web page showing table in Excel cell format ?
danny liu
Ranch Hand
Joined: Jan 22, 2004
Posts: 185
posted
0
If the system delimitor is the same as the delimitor used in CSV file, it can be opened as an Excel file. Otherwise, it cannot.
A better option is to generate real Excel file instead of CSV file. POI from jakarta support such functionality.