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

TdxSpreadSheetDefinedNames.Add(string,string,TdxSpreadSheetCustomView) Method

Adds a new defined name to the collection.

#Declaration

Delphi
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