Back to Devexpress

How to: Rename a Worksheet

windowsforms-15360-controls-and-libraries-spreadsheet-examples-worksheets-how-to-rename-a-worksheet.md

latest1.9 KB
Original Source

How to: Rename a Worksheet

  • Dec 09, 2022

This example demonstrates how to rename a worksheet. To do this, use the Worksheet.Name property of the corresponding Worksheet object.

View Example

csharp
// Change the name of the second worksheet.
workbook.Worksheets[1].Name = "Renamed Sheet";
vb
' Change the name of the second worksheet.
workbook.Worksheets(1).Name = "Renamed Sheet"

When naming a worksheet, take into account the following constraints:

  • The worksheet name must not be equal to an existing name in the collection of worksheets (IWorkbook.Worksheets).
  • The worksheet name must not exceed 31 characters.
  • The worksheet name must not contain the following symbols: , /, ?, :, *, [or].
  • The worksheet name must not start or end with a single quote (‘).
  • The worksheet name must not be an empty string.

The SpreadsheetControl.SheetRenaming and SpreadsheetControl.SheetRenamed events are raised before and after the worksheet is renamed via the control’s UI, respectively.

See Also

Worksheets in Spreadsheet Documents