How to fix the ArgumentOutOfRangeException when accessing a large number of rows and columns?
26 Apr 20241 minute to read
By default, when creating a new workbook, it is set to Excel97to2003 version which supports only 65536 rows and 256 columns. When the row and column index exceeds this limit, an ArgumentOutOfRange exception is thrown. To fix this, the DefaultVersion needs to be set as Xlsx. This version supports 1048576 rows and 16384 columns.
The following code snippet shows how to set the default version of IApplication to Xlsx.
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Xlsx;
IApplication application = excelEngine.Excel
application.DefaultVersion = ExcelVersion.Xlsx