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.
I also faced the same issue, when I was developing a application which exports project contents into excel file.
I could not found the resolution in forums for my problem, then I check the maximum capacity of excel and found below link which says
"Worksheet size 1,048,576 rows by 16,384 columns" and this was the issue in my case, I was exporting more than that rows. Refer below link for details
http://answers.microsoft.com/en-us/office/forum/office_2013_release-excel/with-excel-2013how-many-rows-will-this-contain/271264fb-3ab8-4c5b-aa0d-7095c5ac6108
Regards Prashant Neve
I don't understand the issue. But here is the thing that solved my issue.
Go to Excel Options > Save > Save Files in this format > Select "Excel Workbook(*.xlsx)". Previously, my WorkBooks were opening in [Compatibuility Mode] And now they are opening in normal mode. Range function works fine with that.
I encountered this issue.
Discovered that somewhere in my code I was asking it to count starting from 0 (as you would in a C# code).
Turns out Excel counting starts at 1.
This could also be caused if you have no room on the partition you are saving to.
I checked my HD and foind it was maxed. Moving some un-needed files to a different partition resolved my problem.
Not being able to reply to/endorse this answer, so posting here:
Indeed, the format of the source/destination ranges when moving data from one range to another might cause this error as well.
In my case, the range I wanted to copy contained a date formatted column, and the column contained one cell with an invalid date value (it was not even formatted due to its value, which was a negative integer). So the copy operation between the two ranges was halting at the said cell yielding the very error message discussed here.
The solution in my case was to use Range.Value2 instead of Range.Value, which caused Excel to bypass formatting the cell as a date (more details here). However, this will render your date and time columns to display as integers and decimals. You will, however, be able to change the formats to the desired ones if you know where to expect the date and time values by setting their Range/Column/Cell.NumberFormat property accordingly.
This isn't directly answering the question, but I was getting this error when opening an xlsx file. The problem was that I was using forward slashes in my file path. See also https://stackoverflow.com/a/24635904/5932003. It used to work in previous versions of Excel, but not with Version 1711 (Build 8730.2127).
I was able to diagnose the problem using IDispatch->Invoke(..., EXCEPINFO, ...). The EXCEPINFO object contained a useful description of what went wrong. I was in C++ land, but I suspect that C# code similar to this SO post will do the trick: Packaging IDispatch Invoke with Parameters in C# (with DISPPARAMS).