We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

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);
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.


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


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:
Sample code:

ChartFrame plotArea = chart.getPlotArea();
Area area = plotArea.getArea();

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.

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


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.

You are welcome.