Microsoft EricSavage  -  26 Aug 2009 04:36 pm

Excel Worksheets are not Zero-Based: Exception from HRESULT: 0×800A03EC

I experienced the following message while trying to write to an Excel file from C# code using Interop:

System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A03EC
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at Microsoft.Office.Interop.Excel.Range.set__Default(Object RowIndex, Object ColumnIndex, Object )

The problem was down to inserting values at a zero index.  Excel documents begin their range at 1, not 0.  Now that’s a mindshift for a long-time zero-based programmer!

One Response to “Excel Worksheets are not Zero-Based: Exception from HRESULT: 0×800A03EC”

  1. on 11 Nov 2009 at 12:25 pm 1.Tom said …

    Hi!

    Thank you for that info!

    The same exception may occure if the cultural settings differ from en-US (workaround: http://www.made4dotnet.com/Default.aspx?tabid=141&aid=15).

    Best regards,
    Tom

Trackback This Post | Subscribe to the comments through RSS Feed

Leave a Reply