Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HRESULT: 0x800A03EC on Worksheet.range

I am getting HRESULT: 0x800A03EC on Worksheet.range method. Number of rows are more than 70K. Office 2007.

Code:

Microsoft.Office.Interop.Excel.Range neededRange     = currentWS.Range[cell.Cells[1, 1], cell.Cells[nRowCount, nColumnCount]]; 

Here my rowcount is more than 65530 . Breaks on this function. I have observed that it breaks only when row count goes more than 65530.

like image 816
Cannon Avatar asked Aug 17 '11 21:08

Cannon


1 Answers

This problem occurs if you are using a backwards compatible sheet (a .xls) instead of a .xlsx

To allow sheets to be opened in pre office 2007 version it can't contain more than 65k rows. You can check the number of rows in your sheet by using ctrl+arrowdown till you hit the bottom. If you try to get a range larger than that number of rows it will create an error

like image 86
Eddy Avatar answered Sep 18 '22 14:09

Eddy