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

后端 未结 12 1477
无人共我
无人共我 2020-11-30 12:30

I am working with Window Service project. that have to write data to a sheet in Excel file in a sequence times.

But sometimes, just sometimes, the service throw out

相关标签:
12条回答
  • 2020-11-30 12:51

    I ran to a similar error running Excel in VBA, what I've learned is that when I pull data from MSSQL, and then using get_range and .Value2 apply it's out of the range, any value that was of type uniqueidentifier (GUID) resulted in this error. Only when I cast the value to nvarcahr(max) it worked.

    0 讨论(0)
  • 2020-11-30 12:53

    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.

    0 讨论(0)
  • 2020-11-30 12:53

    I got the error with a space in a Sheet Name:

    using (var range = _excelApp.Range["Sheet Name Had Space!$A$1"].WithComCleanup())
    

    I fixed it by putting single quotes around Sheet Names with spaces:

    using (var range = _excelApp.Range["'Sheet Name Had Space'!$A$1"].WithComCleanup())
    
    0 讨论(0)
  • 2020-11-30 12:53

    The meaning of the completely undocumented error 800A03EC (shame on Microsoft!) is something like "OPERATION NOT SUPPORTED".

    It may happen

    • when you open a document that has a content created by a newer Excel version, which your current Excel version does not understand.
    • when you save a document to the same path where you have loaded it from (file is already open and locked)

    But mostly you will see this error due to severe bugs in Excel.

    • For example Microsoft.Office.Interop.Excel.Picture has a property "Enabled". When you call it you should receive a bool value. But instead you get an error 800A03EC. This is a bug.
    • And there is a very fat bug in Exel 2013 and 2016: When you automate an Excel process and set Application.Visible=true and Application.WindowState = XlWindowState.xlMinimized then you will get hundreds of 800A03EC errors from different functions (like Range.Merge(), CheckBox.Text, Shape.TopLeftCell, Shape.Locked and many more). This bug does not exist in Excel 2007 and 2010.
    0 讨论(0)
  • 2020-11-30 12:57

    Interesting enough, this error also occurs, at time of opening when the .XLS? file is incorrectly formed or require repairs.

    A hard to find error is to many rows on a .xls (old excel) file.

    Test it: manually open the affected file with excel desktop .

    I use automation to process a few hundred files daily, when this error show up, I notify the owner via mail and save the unprocessed file on a temporary location.

    0 讨论(0)
  • 2020-11-30 13:00

    I have encountered this error code when enumerating names and calling worksheet.get_Range(name). It seems to occur when the name does NOT apply to a range, in my case it is the name of a macro.

    0 讨论(0)
提交回复
热议问题