WorkSheet max row count exception

Hi,
I have a problem with bellow code:

ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet sheet = workbook.Worksheets[0];

for (something)
{
row++;
sheet.Range[row, 1].Text = "something";
}
.......

when row == 65537 throws an exception:

Message: Specified argument was out of the range of valid values.
Source: Syncfusion.XlsIO.Web

Exception Stack Trace:
----------------------
at Syncfusion.XlsIO.Implementation.RangeImpl.CheckRange(Int32 row, Int32 column)
at Syncfusion.XlsIO.Implementation.RangeImpl.get_Item(Int32 row, Int32 column)

1 Reply

GM Geetha M Syncfusion Team June 9, 2009 09:05 AM UTC

Hi Mityo,

Thank you for your interest in Syncfusion products.

It is not possible to have more than 65536 rows in XLS format. It is the limitation of MS Excel and by default XlsIO creates the file in XLS format. But it is possible to have 1048576 rows in XLSX format. Please try using the code snippet given below:

IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2007;
IWorkbook workbook = application.Workbooks.Create(1);

and save the file in XLSX format as below:

workbook.SaveAs("Sample.xlsx");
workbook.Close();
excelEngine.Dispose();

Please try this and let me know if you have any questions.

Regards,
Geetha

Loader.
Up arrow icon