vcl-dxspreadsheetcore-dot-tdxcustomspreadsheet-dot-addsheet-x28-system-dot-string-dxspreadsheetcore-dot-tdxspreadsheetcustomviewclass-x29.md
Adds a new empty worksheet to the current document.
function AddSheet(const ACaption: string = ''; AViewClass: TdxSpreadSheetCustomViewClass = nil): TdxSpreadSheetCustomView;
| Name | Type | Description |
|---|---|---|
| ACaption | string |
Optional. The created worksheet’s caption. The ACaption property value initializes the created worksheet’s Caption property. All worksheet names must be unique in the document; otherwise, an exception occurs.
The specified caption’s length (in characters) should not exceed the dxSpreadSheetMaxCaptionLength global constant value; otherwise, an exception occurs.
The caption length limitation ensures compatibility with supported popular spreadsheet document formats.
If you omit this parameter, the function automatically generates a name that consists of the 'Sheet' string followed by a number.
| | AViewClass | TdxSpreadSheetCustomViewClass |
Optional. Specifies the created worksheet’s type (the class-reference to a terminal TdxSpreadSheetCustomView descendant).
If you omit this parameter, the function creates a TdxSpreadSheetTableView class instance.
Note
In v25.2, Spreadsheet controls support only TdxSpreadSheetTableView worksheets.
|
| Type | Description |
|---|---|
| TdxSpreadSheetCustomView |
The created worksheet.
Tip
You need to cast the returned object to the actual worksheet class (a terminal TdxSpreadSheetCustomView descendant whose reference is passed as the AViewClass parameter) to access all public API members.
|
Call the AddSheet functions to add new worksheets to the current spreadsheet document. The created worksheet is accessible through Sheets and VisibleSheets properties. The active worksheet does not change.
A user can click the New Worksheet button or press the Shift + F11 keystroke to create a new worksheet with an automatically generated name.
In addition, you can create the InsertSheet user command (action object) and link it to a UI element in your application. The automatic Ribbon/Toolbar UI generator creates this command and associates it with the corresponding Ribbon or toolbar item.
See Also
TdxCustomSpreadSheet.ActiveSheet Property
TdxCustomSpreadSheet.ActiveSheetIndex Property