Obtaining Excel worksheet reference by worksheet name via C#

calendar_today Asked Mar 22, 2010
thumb_up 17 upvotes
history Updated April 16, 2026

Question posted 2010 · +7 upvotes

I’m currently obtaining a handle to a Excel worksheet by using the below C# code:

*Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(15);//Get the worksheet “SubSignOff” number*

Is there any way that I can obtain the same by using the worksheet name — “SubSignOff” ?

Many thanks for your help.

–Chapax

Accepted answer +17 upvotes

Instead of the using Excel.Workbook.Sheets collection, it’s easier to access the Excel.Workbook.Worksheets collection, that way you can utilize early binding.

In your case, it could look something like the following:

Excel.Application excelApp = new Excel.Application();
excelApp.Visible = true;

Excel.Workbook workbook = excelApp.Workbooks.Open("C:MyWorkbook.xls",
    Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, 
    Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, 
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);

// The key line:
Excel.Worksheet worksheet = (Excel.Worksheet)workbook.Worksheets["SubSignOff"];

Hope this helps…

Excel VBA objects referenced (5)

Top excel Q&A (6)

+17 upvotes ranks this answer #35 out of 167 excel solutions on this site — top 21%.