Skip to main content

TdxSpreadSheetDefinedNames.Add(string,string,TdxSpreadSheetCustomView) Method

Adds a new defined name to the collection.

Declaration

function Add(const ACaption: string; const AReference: string; AScope: TdxSpreadSheetCustomView = nil): TdxSpreadSheetDefinedName;

Parameters

Name Type Description
ACaption string

A defined name’s caption.

AReference string

A defined name’s reference.

AScope TdxSpreadSheetCustomView

A defined name’s scope. The created defined name’s scope is the entire document. To limit the scope to a worksheet, pass it as the AScope parameter.

Returns

Type Description
TdxSpreadSheetDefinedName

The created defined name.

Remarks

The Add procedure validates if the accepted defined name caption:

  • Is not an empty string.

  • Starts with a letter or underscore.

  • Does not match a reference.

  • Includes only letters, numbers, periods, and underscore character.

  • Does not match an existing name’s caption in the document.

If the caption is invalid, an Add procedure call creates no defined name and raises an EdxSpreadSheetDefinedNameError exception.

The following code example shows how to create the NameA defined name that refers to the A1 cell in the first worksheet (that is, the sheet whose tab occupies the leftmost position in the caption bar):

//...
  dxSpreadSheet1.DefinedNames.Add('NameA', '=Sheet1!A1', dxSpreadSheet1.Sheets[0]);
See Also