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
Hello Myles,
I have tested this with Excel file that has size 1.49MB and the sample project is working without throwing any errors. I have attached the file here so you could test it on your side. Would you please let me know if an error is thrown when you load it? In order to investigate this issue further for you I will need a sample project and a file where the issue is reproducible. It will be very helpful if you could modify the attached files so that they represent your scenario and the exception is thrown. Thank you in advance.
I am just checking if this is still an issue for you and if you were able to reproduce the issue running the attached project.
Hello Maria,
We too are facing the OutOfMemory issue when loading the excel file. The file is of size 82 MB and has 9 billion rows and 15 columns. Can you please let us know whether Infragistics Excel engine has any limit on file size to be loaded in an object at a time?