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;
try
{
output = workbook.SaveToStream();
Have you got any idea ? Thanks a lot.
Hi,

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.
e.g
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.


Hi,


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.