Free Support Forum - aspose.com

Worksheet index by name

Hi all,


Just trying to get the index of a worksheet from template that contains 6 worksheets. How do I get the index of a worksheet by using the worksheet name?

So for example I can then set the activesheet?

Thanks

Steve

Hi,


You may use Worksheet.Index property to get the index of the worksheet in the workbook, see the code segment:

Sample code:


Workbook wb = new Workbook(“e:\test\Book1.xlsx”);
Worksheet sheet = wb.Worksheets[“MySheet”];
int idx = sheet.Index;

Thank you.