cancel
Showing results for 
Search instead for 
Did you mean: 

Export To Excel problem with HSSFWorkbook

Former Member
0 Kudos

Hi all,

In a webdynpro application, we are writing data from webdynpro context to excel sheet using HSSFWorkbook. Below is the code

This works fine when there are only 500 to 600 records .But if there are more than 500-600 records excel gets corrupted and error message is displayed.

While going through different forum I found this is due to encoding. When I comment the for loop in code below, problem doesnu2019t exists any more.Even 10000 records are successfully displayed.

Please guide :

How encoding is causing this problem and how can I rectify this?

What exactly this code (code in bold in below code snippet ) is checking ?

What will be effect if I remove this code as this webdynpro application is used in many countries ?

public byte[] exportFile() throws Exception{

InputStream stream = new ByteArrayInputStream(xslSource);

HSSFWorkbook workbook = new HSSFWorkbook(stream);

stream.close();

process(workbook,true);

ByteArrayOutputStream bos = new ByteArrayOutputStream();

workbook.write(bos);

byte[] retorno = bos.toByteArray();

for(int c=1;c<retorno.length-1;c++){

if(retorno[c-1]==0 && retorno[c]==-125 && retorno[c+1]==1){

retorno[c]=(byte)3;

}else if(retorno[c-1]==63 && retorno[c]==67 && retorno[c+1]!=0){

retorno[c]=(byte)35;

}

}

bos.close();

return retorno;

}

Regards ,

Madhvika

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi

check this blog

/people/subramanian.venkateswaran2/blog/2006/08/16/exporting-table-data-to-ms-excel-sheetenhanced-web-dynpro-binary-cache

Former Member
0 Kudos

Solved

Former Member
0 Kudos

Hi,

Even we are facing the same issue with large data, could you please let us know how you solved ?

Thanks,

Sanjay.