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

Free Support Forum - aspose.com

Saving MS Excel Workbook to streams via Aspose.Cells

I use Aspose.cells 8.5.0

I want to get the MemoryStream from my workbook which is an xlsm document. All sheets are filled.
Then I got a null pointer exception.

System.IO.MemoryStream output = null;
output = workbook.SaveToStream();
Have you got any idea ? Thanks a lot.

Thanks for providing us some details.

Please do not use workbook.SaveToStream() method because it saves to XLS format only. If you want to save in other formats like XLSX/XLSM, kindly use workbook.Save(stream, saveFormat) overloaded version of the method. See the sample lines of code.
Sample code:

MemoryStream memoryStream = new MemoryStream();
workbook.Save(memoryStream, SaveFormat.Xlsm);

Let us know if you still have any issue.

Thank you.

Thanks a lot !

It is the solution due to the format xlsm.


Good to know that your issue is sorted out by following the suggestion. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.