Adding Worksheets to a Workbook |
The ExcelWorkbook class offers access to its collection of worksheets using the Worksheets property. By default, when a workbook is created, its Worksheets collection contains a single worksheet. More worksheets can be added to the collection using the AddWorksheet(String) method. You can add a worksheet with the default name or you can specify the name of the new worksheet as parameter.
Below there is a sample code that show how to add a second worksheet with the name 'Simple Chart' to the workbook:
A reference to a worksheet from the current workbook can be obtained using one of the two index properties of the ExcelWorksheetsCollection. The first one returns the worksheet at the specified zero based index and the second one returns the worksheet with the specified name: