Hi All,

I am writing jsp to export data in excel format to user. An excel could be recieved on the cient side.
However, since there's large amount of data, and I don't want to keep it in the server memory and write them at the end. I try to divide them and write serveral times. However, each extra write(..) will cause an extra new lines at the top of the excel worksheet and then the extra data is placed after these new lines. Does anyone know the reasons?

The code is something like this:

    response.setHeader("Content-Type", "application/octet-stream"); 

    responseContent ="<table><tr><td>12131</td></tr>.......";
    byte[] responseByte1 = responseContent.getBytes("utf-16");
    outputStream.write(responseByte1, 0, responseByte1.length ); 

    responseContent =".....<tr><td>12131</td></tr></table>";
    byte[] responseByte2 = responseContent.getBytes("utf-16");
    outputStream.write(responseByte2, 0, responseByte2.length ); 


Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

8 Years
Discussion Span
Last Post by sam.wonghk

thanks for helping to format my code. sorry that i am a newbie of this forum.

I found my description is really not clear. Attached is an example of the excel result to make my problem clear to you. Thanks so much.

Attachments excel_results.png 66.66 KB
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.