You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Amol Khedkar <ds...@bww.com> on 2003/10/01 22:35:12 UTC

Excel Download Issues

Hi! As part of an ongoing project, I've provided a link for users to 
download data in Excel format. This link actually calls a JSP, which 
performs the necessary work to collect the data. The data is then loaded 
into an Excel workbook (with multiple) sheets and is formatted as per the 
users' requirements (colors, fonts, data formats, etc.). 

Things almost work as expected. The first 2-3 downloads are as expected. 
Then, from the next time onwards, the downloaded Excel file does not have 
any formatting in it and/or the formatting goes wild (colors, fonts, etc. 
appear in unexpected places). On my development setup, I've noticed that 
restarting the server usually causes things to back to normal. Of course, 
this cannot be a solution for production purposes. 

Here's the setup: I'm using Websphere Studio Application Developer on a NT 
machine for development. The target environment is an AIX/Websphere combo. 
After the workbook object is created & populated, I write it to a 
ByteArrayOutputStream. Then I use the toByteArray() method to get the 
contents as a byte array which is ultimately downloaded as an Excel file, 
using the output stream of the response. The header content type is set 
to "application/msexcel". The header is set to "Content-Disposition", with 
the default name of the download file specified (eg. myData.xls). The 
content length is set to the size of the byte array. 

The question: how do I go about ensuring that every time a user attempts to 
download data, they see it with the proper formatting? Am I doing something 
incorrect to cause this behavior? 

Please help soon, I've got my back to the wall! 

Cheers! 

-- Amol. 

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


Re: Excel Download Issues

Posted by Danny Mui <da...@muibros.com>.
I'm on plain jane NT/Websphere (through a servlet albeit) and dont seem 
to have any problems there.  The only difference here is I pass the 
servlet output stream to the HSSFWorkbook to write out explicitly.

Are you saving the workbook or opening it up from scratch?

For those type of operations, the voodoo response.reset() call helps 
before doing any of the header stuff.

danny

Amol Khedkar wrote:

>Hi! As part of an ongoing project, I've provided a link for users to 
>download data in Excel format. This link actually calls a JSP, which 
>performs the necessary work to collect the data. The data is then loaded 
>into an Excel workbook (with multiple) sheets and is formatted as per the 
>users' requirements (colors, fonts, data formats, etc.). 
>
>Things almost work as expected. The first 2-3 downloads are as expected. 
>Then, from the next time onwards, the downloaded Excel file does not have 
>any formatting in it and/or the formatting goes wild (colors, fonts, etc. 
>appear in unexpected places). On my development setup, I've noticed that 
>restarting the server usually causes things to back to normal. Of course, 
>this cannot be a solution for production purposes. 
>
>Here's the setup: I'm using Websphere Studio Application Developer on a NT 
>machine for development. The target environment is an AIX/Websphere combo. 
>After the workbook object is created & populated, I write it to a 
>ByteArrayOutputStream. Then I use the toByteArray() method to get the 
>contents as a byte array which is ultimately downloaded as an Excel file, 
>using the output stream of the response. The header content type is set 
>to "application/msexcel". The header is set to "Content-Disposition", with 
>the default name of the download file specified (eg. myData.xls). The 
>content length is set to the size of the byte array. 
>
>The question: how do I go about ensuring that every time a user attempts to 
>download data, they see it with the proper formatting? Am I doing something 
>incorrect to cause this behavior? 
>
>Please help soon, I've got my back to the wall! 
>
>Cheers! 
>
>-- Amol. 
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: poi-user-help@jakarta.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org