Hresult: 0X800A03Ec on Worksheet.Range

HRESULT: 0x800A03EC on Worksheet.range

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

Excel error HRESULT: 0x800A03EC while trying to get range with cell's name

The error code 0x800A03EC (or -2146827284) means NAME_NOT_FOUND; in other words, you've asked for something, and Excel can't find it.

This is a generic code, which can apply to lots of things it can't find e.g. using properties which aren't valid at that time like PivotItem.SourceNameStandard throws this when a PivotItem doesn't have a filter applied. Worksheets["BLAHBLAH"] throws this, when the sheet doesn't exist etc. In general, you are asking for something with a specific name and it doesn't exist. As for why, that will taking some digging on your part.

Check your sheet definitely does have the Range you are asking for, or that the .CellName is definitely giving back the name of the range you are asking for.

Excel throws HRESULT: 0x800A03EC exception when using Range

Cells() takes two integer parameters for row and column, or a string parameter for a single cell address. If you want to target a range, you need to use Worksheet.Range instead of Worksheet.Cells. Worksheet.Range can accept a starting and ending cell address, such as:

wSheet.Range("A1", "AD413").Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous

In your case, since you already have the string "A1:AD413" in a variable called range, you could just change the cell-formatting lines to:

wSheet.Range(range.Split(":")(0), range.Split(":")(1)).Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous

Exception from HRESULT: 0x800A03EC Error

Got same error in this line

 Object temp = range.Cells[i][0].Value;

Solved with non-zero based index

 Object temp = range.Cells[i][1].Value;

How is it possible that the guys who created this library thought it was a good idea to use non-zero based indexing?

Exception HRESULT: 0x800A03EC when inserting an Excel formula

Excel's COM interface speaks American so you need to use the US list separators in the formula strings. replace your semicolons with commas and you should be fine.

Range rng = activeWorksheet.get_Range("A1");
rng.FormulaArray = "=SUM(A4*C4,A5*C5,A6*C6,A7*C7)/SUM(A4:A7)";

Why do I get the error Exception from HRESULT: 0x800A03EC when I deploy my mvc application to a live server using iis?

Using Office Interop on a server is not supported.

The linked article describes some of the problems you will face. I would recommend using an alternative such as EPPlus, or a commercial product such as Aspose Cells.

Exception from HRESULT: 0x800A03EC creating new worksheet

With xlApp.Worksheets.Add("Sheet1") you're trying to add a new worksheet before Sheet1, it expects an existing Worksheet object (and 0x800A03EC is NAME_NOT_FOUND).

I suppose what you're trying to do is to add a new sheet named Sheet1:

 Worksheet xlWorksheet = xlApp.Worksheets.Add();
xlWorksheet.Name = "Sheet1";

Now also the line xlWorksheet = (Worksheet)xlWorkbook.Worksheets.get_Item("Sheet1");
can be simply dropped.



Related Topics



Leave a reply



Submit