I am trying to load a .xlsx format Excel file by using the following code:
private Workbook _workbook;
using (Stream stream = fileStream) { _workbook = Workbook.Load(fileStream, false); }The load always fails with an exception message of "Out of Memory". The stack trace is: at System.Drawing.Graphics.FromImage(Image image) at Infragistics.Documents.Excel.Serialization.Excel2007.SharedContentTypes.ImageBasePart.GetImageHolder(Stream imageStream) at Infragistics.Documents.Excel.Serialization.Excel2007.SharedContentTypes.ImageBasePart.Load(Excel2007WorkbookSerializationManager manager, Stream contentTypeStream) at Infragistics.Documents.Excel.Serialization.Excel2007.Excel2007WorkbookSerializationManager.LoadPart(IPackagePart part) at Infragistics.Documents.Excel.Serialization.Excel2007.Excel2007WorkbookSerializationManager.LoadPartRelationships(IEnumerable`1 relationships, ContentTypeBase contentType, Boolean isPostLoad) at Infragistics.Documents.Excel.Serialization.Excel2007.Excel2007WorkbookSerializationManager.LoadPartRelationships(IEnumerable`1 relationships, ContentTypeBase contentType) at Infragistics.Documents.Excel.Serialization.Excel2007.Excel2007WorkbookSerializationManager.LoadPart(IPackagePart part) at Infragistics.Documents.Excel.Serialization.Excel2007.Excel2007WorkbookSerializationManager.LoadPartRelationships(IEnumerable`1 relationships, ContentTypeBase contentType, Boolean isPostLoad) at Infragistics.Documents.Excel.Serialization.Excel2007.Excel2007WorkbookSerializationManager.LoadPartRelationships(IEnumerable`1 relationships, ContentTypeBase contentType) at Infragistics.Documents.Excel.Serialization.Excel2007.Excel2007WorkbookSerializationManager.LoadPart(IPackagePart part) at Infragistics.Documents.Excel.Serialization.Excel2007.Excel2007WorkbookSerializationManager.LoadPartRelationships(IEnumerable`1 relationships, ContentTypeBase contentType, Boolean isPostLoad) at Infragistics.Documents.Excel.Serialization.Excel2007.Excel2007WorkbookSerializationManager.LoadPart(IPackagePart part) at Infragistics.Documents.Excel.Serialization.Excel2007.Excel2007WorkbookSerializationManager.LoadPartRelationships(IEnumerable`1 relationships, ContentTypeBase contentType, Boolean isPostLoad) at Infragistics.Documents.Excel.Serialization.Excel2007.Excel2007WorkbookSerializationManager.LoadPartRelationships(IEnumerable`1 relationships, ContentTypeBase contentType) at Infragistics.Documents.Excel.Serialization.Excel2007.Excel2007WorkbookSerializationManager.LoadWorkbookContents() at Infragistics.Documents.Excel.Serialization.WorkbookSerializationManager.Load() at Infragistics.Documents.Excel.Workbook.LoadXLSXFile(Workbook workbook, Stream stream, IPackageFactory packageFactory, Boolean verifyExcel2007Xml) at Infragistics.Documents.Excel.Workbook.LoadHelper(Stream stream, WorkbookFormat format, String parameterName, IPackageFactory packageFactory, Boolean verifyExcel2007Xml) at Infragistics.Documents.Excel.Workbook.Load(Stream stream, IPackageFactory packageFactory, Boolean verifyExcel2007Xml) at Infragistics.Documents.Excel.Workbook.Load(Stream stream, Boolean verifyExcel2007Xml)Any ideas what is causing this? How can I get round this issue?
Hello,
Thank you for posting!
I have created a sample project trying to reproduce the behavior you have described. In the attached project a filestream is used to load data from excel file and populate it in a grid. No exception occurs when running this application on my side. Would you please try to load it and let me know if the error message is thrown? Please note the the path for the file should be changed according to the projects location on your computer. Could you give me more details about the excel file you are trying to load? Does it contain lots of worksheets, rows and columns? It will be very helpful if you could modify the attached project so that it represents your issue. Thank you.
The spreadsheet you include is tiny and contains a couple of cell values. Not very realistic of real world examples. The spreadsheets that I am having the issue with range in size from 1,458KB to 8434KB. Yes they all contain multiple worksheets (max number of 9) and many rows (100s of rows....but not 1000s).
I am able to load your 9KB spreadsheet without any issues.
Regards
Myles