workbook.save(responseStream, com.aspose.cells.SaveFormat.XLSX) Unable to get outputStream bytes after workbook save

Hi Aspose Team,
I am using a file upload service in my project. I need to pass the outputStream after the workbook is saved but outputStream byte length is always 0.
For Ex:
this.workbook.save(responseStream, com.aspose.cells.SaveFormat.XLSX);
fileService.upload(responseStream, filename, …);
For your reference:
I am getting outputStream as bytes in OoxmlSaveOptions as below.
workbook.save(responseStream, ooxmlSaveOptions);
Query:
why outputStream is always 0 byte in saveFormat/XlsSaveOptions.
1)this.workbook.save(responseStream, new XlsSaveOptions()); OR
2)this.workbook.save(responseStream, com.aspose.cells.SaveFormat.XLSX);
Please reply back as soon as possible.
Thanks

@manikandan123,

Could you please share standalone (runnable) sample code which can be executed without compile time errors. We will check your issue soon.

Test.zip (7.2 MB)
Please have some look into this standalone code @Amjad_Sahi

@manikandan123,

Aspose.Cells saves to byte array output streams via Workbook.save() overloads which surely has size or length. I tried to use the following (updated) code segment and it works as expected:
e.g.
Sample code:


ChartFrame plotArea = chart.getPlotArea();
Area area = plotArea.getArea();
area.setForegroundColor(com.aspose.cells.Color.getWhite());

ByteArrayOutputStream out = new ByteArrayOutputStream();
workbook.save(out, SaveFormat.XLSX);
System.out.println(“Size of OutputStream:” + out.size());
System.out.println(“Length of OutputStream bytes:”+out.toByteArray().length);

I guess your last part of code where you are writing to the stream is not right, the writeTo method requires some file output stream to be saved. So, you may use the devised code (as mentioned above) for your needs.

@manikandan123,
You may also try by simply replacing the following line of code and keep rest of the code same:

//test.writeTo(out);
test.write(((ByteArrayOutputStream)out).toByteArray(),0,((ByteArrayOutputStream)out).size()); 

This will return output as:
Lengh of OutputStream bytes:11205

Thanks… It works fine.

Thanks for the formation about workbook.save… It works fine now.

@manikandan123,
You are welcome.