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.

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

Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0

steve francisco
Ranch Hand

Joined: Jan 26, 2005
Posts: 46

posted Feb 02, 2005 21:22:00

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

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 Feb 02, 2005 21:27:00

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 ??