NativeExcel2 for .Net Developer's Reference

IWorksheets.AddMethod(Object, Object)

Creates a new worksheet. You can insert the new worksheet either before or after an existing worksheet.

[Visual Basic]
FunctionAdd(_
ByValBeforeAsObject,_
ByValAfterAsObject_
)AsIWorksheet
[C#]
IWorksheetAdd(
objectBefore,
objectAfter
);
[C++]
IWorksheet*Add(
Object*Before,
Object*After
);
[JScript]
functionAdd(
ObjectBefore,
ObjectAfter
):IWorksheet;

Parameters

Before
An object that specifies the worksheet before which the new worksheet is added. Can be either an IWorksheet interface, Number which indicates the worksheet index or String which indicates the worksheet name.
After
An object that specifies the worksheet after which the new worksheet is added. Can be either an IWorksheet interface, Number which indicates the worksheet index or String which indicates the worksheet name.

Return Value

IWorksheet interface.

Example

This example creates a new worksheet after sheet with name "Sheet3".

[C#]
book.Worksheets.Add(null, "Sheet3");
[VisualBasic]
book.Worksheets.Add(Nothing, "Sheet3")
[C++]
book->Worksheets->Add(null, S"Sheet3");
This example creates a new worksheet before first worksheet.
[C#]
book.Worksheets.Add(book.Worksheets[1], null);
[VisualBasic]
book.Worksheets.Add(book.Worksheets(1), Nothing)
[C++]
book->Worksheets->Add(book->Worksheets->Item[1], null);

See Also

IWorksheets Interface | NativeExcel Namespace | IWorksheets.Add Overload List