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.