OutOfMemoryException opening very large .xlsx file

31 views
Skip to first unread message

Oliver Bock

unread,
Jul 29, 2019, 10:09:58 PM7/29/19
to CSVChat
Hi Bruce,

I am getting an OutOfMemoryException ("Array dimensions exceeded supported range") when I try to open a large Excel file, with 457948 rows and 1043 columns.  This surprises me because the product of these two numbers is well within the range of an int32 (477,639,764).

     DataStreams.dll!DataStreams.Xlsx.OOXml.Read.Worksheet.Worksheet(System.IO.Stream data, DataStreams.Xlsx.OOXml.Read.Workbook wkBook)    Unknown
     DataStreams.dll!DataStreams.Xlsx.OOXml.Read.Workbook.Workbook(System.IO.Stream data)    Unknown
     DataStreams.dll!DataStreams.Xlsx.XlsxReader.XlsxReader(System.IO.Stream inputStream)    Unknown
     ... my code ...

I am using v5.24 in 64-bit mode.  Unfortunately I cannot share the data file, but I can perhaps get you a line number if you can give me the .pdb files.  I can also install the latest version, though I don't see anything in the release notes that looks relevant.

I guess that this line (decompiled) is the proximate cause of the problem

    this.Cells = new string[point.Y + 1, point.X + 1];

and I can tell you that worksheet/dimension@ref=A1:ANC457947, but I didn't get further than that.  There is only one sheet in the file.

Is there anything else I can provide?

Regards,
  Oliver

shriop

unread,
Jul 30, 2019, 12:12:55 AM7/30/19
to CSVChat
It appears that you ran into the 2GB max memory limit on arrays. It looks like there's an app.config override that will let you get past it, https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/gcallowverylargeobjects-element .

Bruce Dunwiddie

Oliver Bock

unread,
Jul 30, 2019, 5:24:15 AM7/30/19
to csv...@googlegroups.com
Hi Bruce,

Yes, that fixed it.  Thanks.

Regards,
  Oliver

--
You received this message because you are subscribed to the Google Groups "CSVChat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to csvchat+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/csvchat/cc0470f6-2058-474c-8c9d-b69de7fc453c%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages