Skip to main content

TdxCustomSpreadSheet.AddSheet(string,TdxSpreadSheetCustomViewClass) Method

Adds a new empty worksheet to the current document.

Declaration

function AddSheet(const ACaption: string = ''; AViewClass: TdxSpreadSheetCustomViewClass = nil): TdxSpreadSheetCustomView;

Parameters

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 v24.1, Spreadsheet controls support only TdxSpreadSheetTableView worksheets.

Returns

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.

Remarks

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.

End-User Functionality

A user can click the New Worksheet button or press the Shift+F11 keystroke to create a new worksheet with an automatically generated name.

UI Command/Action

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