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

Free Support Forum - aspose.com

Error in GridDesktop.ImportExcelFile from MemoryStream


I'm retrieving text from a DB which contains the SpreadsheetML representation of an XLS file; I want to take that text into a MemoryStream and load that into the GridDesktop control. The the user will make changes, and I want to save the spreadsheet XML back to the DB. So far, I get an "Object reference not set to an instance of an object." error when trying to open the file from a MemoryStream. Here is the code:

public void SetActiveWorkbook(string content)


MemoryStream ms = new MemoryStream();

ASCIIEncoding ascEncoding = new ASCIIEncoding();

byte[] xmlBytes = ascEncoding.GetBytes(content);

ms.Write(xmlBytes, 0, xmlBytes.Length);


ms.Seek(0, SeekOrigin.Begin);

gridDesktop.ImportExcelFile(ms); //error here


Another question, is there a way to create an Aspose.Cells.Workbook and then assign that instance to the GridDesktop?



Well, I am afraid, currently Aspose.Cells.GridDesktop can only import xls, xlsx, csv files etc. I have logged your request into out issue tracking system with an issue id: CELLSNET-16834. We will look into it and get back to you soon.

For your second query, well, Aspose.Cells library and Aspose.Cells.GridDesktop are different components (one is library and other is control) and have different architectures and attributes, so, the conversion is not possible.

Thank you.


Well, the GridDesktop control supports importing
SpreadsheetML file format in the recent versions: Aspose.Cells for .NET (Latest Version) You may download and get the latest control (GridDesktop) from it. Please try it and let us know. The exception may be caused by a particular SpreadsheetML
file. So, if you still find the issue, please post your file here.

We will check it soon.

Thank you.