Monthly ArchiveAugust 2009
Microsoft 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!
