Hi Guys I know that this question has been asked and answered many times before but I have tried all sorts. I am trying to use a servlet to generate and present a report in Excel format. I believe that the easiest way to do this is to generate the content as an HTML table and then 'fool' the client browser into opening it in Excel by setting the Content Type etc. This servlet works fine if I set the Content Type to "text/html" but if I set the content type to "application/vnd.ms-excel" then I get an error from Excel saying that it could not open the URL.
I am totally puzzled. Has anyone got any idea what I am doing wrong ? Thanks Andy
Andy Bowes<br />SCJP, SCWCD<br />I like deadlines, I love the whoosing noise they make as they go flying past - Douglas Adams
If you claim that the content type is "application/vnd.ms-excel", the browser and Excel will expect a binary stream -- the BIFF8 .xls file. You'd be better off setting the content type to "application/csv" and printing out the table as comma-separated values. Or, if you want to get really fancy, you can use Jakarta POI to generate the real thing...
I have also tried generating CSV content as follows :
But I still get the resource not found error when the content type is set to "text/csv". If I set the content type to "text\html" then the content is displayed correctly in the browser. This is only a cut down version of the servlet that I am attempting as the content that I want to send to Excel will be generated by an XSL transfromation hence the reason why I want to use a HTML table or CSV rather than use POI or some other alternative. Does anyone out there have a servlet that generates Excel files I can copy. thanks Andy