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-disposition","attachment;filename=DocuShareSearch.xls");
    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 ); 

    outputStream.close();

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.