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

Free Support Forum - aspose.com

Error opening a workbook from a MemoryStream

Dear All,

I’m trying to open a workbook from a memorystream but I get the error: "Object reference not set to an instance of an object."

I use Aspose.Cells.dll 7.3.3.

My code is :
Dim stream As New MemoryStream(result) 'result is byte()
Dim loadOptions As New Aspose.Cells.LoadOptions(Aspose.Cells.LoadFormat.Xlsx)
Dim wbk As New Aspose.Cells.Workbook(stream, loadOptions)

Please, could you help to fix my code.

Best regards,


There might be some problem with your MemoryStream, see the sample code below:

Sample code:

Dim fs As FileStream = File.Open(“e:\test2\userexcel.xlsx”, FileMode.Open)
Dim buffer(fs.Length - 1) As Byte
fs.Read(buffer, 0, buffer.Length)
Dim ms As New MemoryStream(buffer)
Dim loadOptions As New LoadOptions(LoadFormat.Xlsx)
Dim workbook As New Workbook(ms, loadOptions)

Also, please try our latest fix/version: Aspose.Cells for .NET v7.3.3.1 and let us know your feedback.

If you still find the issue, kindly attach your template Excel file here, we will check it soon.

Thank you.

You’re right my MemoryStream was wrong for the Xlsx format.

I changed in LoadFormat.Excel97To2003 the loadOptions and it works fine.

Thank you very much.


Good to know that your issue is resolved.

Feel free to contact us any time if you need further help or have any other issue. We will help you soon.

Thank you.