Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Add a New Worksheet

  • 2 minutes to read

This example demonstrates how to add a new worksheet to a workbook. To do this, use the WorksheetCollection.Add method of the WorksheetCollection collection accessed via Workbook.Worksheets.

To insert a worksheet at the specified position in the WorksheetCollection collection, call the WorksheetCollection.Insert method with the passed worksheet zero-based index.

To specify a worksheet name, use the Worksheet.Name property or pass the worksheet name to the WorksheetCollection.Add or WorksheetCollection.Insert method as a parameter.

View Example

// Add a new worksheet to the workbook. 
// The worksheet will be inserted into the end of the existing collection of worksheets.
// Worksheet name is "SheetN", where N is a number following the largest number used in existing worksheet names of the same type.
workbook.Worksheets.Add();

// Add a new worksheet under the specified name.
workbook.Worksheets.Add().Name = "TestSheet1";

workbook.Worksheets.Add("TestSheet2");

// Add a new worksheet at the specified position in the collection of worksheets.
workbook.Worksheets.Insert(1, "TestSheet3");

workbook.Worksheets.Insert(3);