Working with Excel Worksheet in C#

2

I have a Excel version problem with an Windows Forms Tool.

Microsoft.Office.Interop.Excel.Worksheet ws = myExcelWorkbook.Worksheets[3];
ws.Delete();
 ws = myExcelWorkbook.Worksheets[3];

This works perfectly with Excel 2010 but throws the following Exception in

Excel 2013: "0x8002000B DISP_E_BADINDEX"

c#
.net
excel
ms-office
asked on Stack Overflow Dec 9, 2015 by xileb0 • edited Dec 9, 2015 by Soner Gönül

1 Answer

1

Excel only creates one Worksheet in a new document by default, unlike 3 Worksheets for Excel 2010.

So BADINDEX means you don't have an Index of 3

answered on Stack Overflow Dec 9, 2015 by Matt

User contributions licensed under CC BY-SA 3.0