Jason B Herald x = sin x

14Sep/080

Java, Struts and Outputing an Excel File

In a project I was working on last night I needed to output sets of data on demand in excel.  I found various ways to do this however this was the most simplistic and worked every time on all my computers. (Mac, Linux, XP).

response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","inline" );

Those 2 lines make the instant translation of the HTML I put in the page go to excel.  Now something massive to remember here: The formatting is pretty unpredictable if you use css or any fruity styles.  Luckally in my case I didn't need to use either; just output the data.

In either case you simply draw the HTML as you would to output a basic page with the response lines telling your browser that excel owns the page.

Filed under: Code, Java Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

You must be logged in to post a comment.

No trackbacks yet.

 

September 2008
M T W T F S S
« Aug   Oct »
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

Pages