HotXLS Docs

TXLSXDefinedName and TXLSXDefinedNames classes

TXLSXDefinedNames owns workbook and worksheet scoped Excel names through TXLSXWorkbook.DefinedNames and each item is a TXLSXDefinedName declared in lxHandleX

Declarations

type
  TXLSXDefinedName = class
    constructor Create(const AName, AFormula: WideString; ASheetIndex: Integer = -1);
    property Name: WideString;
    property Formula: WideString;
    property SheetIndex: Integer;
    property Visible: Boolean;
    property Hidden: Boolean;
    property Comment: WideString;
  end;

  TXLSXDefinedNames = class
    function Add(const AName, AFormula: WideString): Integer; overload;
    function Add(const AName, AFormula: WideString; ASheetIndex: Integer): Integer; overload;
    function FindByName(const AName: WideString): TXLSXDefinedName; overload;
    function FindByName(const AName: WideString; ASheetIndex: Integer): TXLSXDefinedName; overload;
    function DeleteByName(const AName: WideString): Boolean; overload;
    procedure Delete(Index: Integer);
    procedure Clear;
    property Count: Integer;
    property Items[Index: Integer]: TXLSXDefinedName; default;
  end;

Key members

FormulaFormula or range reference stored without a leading equals sign
SheetIndex-1 creates a workbook name and a zero-based sheet index creates a local name
Visible and HiddenComplementary views of the Excel Name Manager hidden attribute
CommentOptional note persisted in the OOXML defined-name metadata
FindByNameYields nil when no matching name exists in the requested scope

Example

Workbook.DefinedNames.Add('SalesTotal', 'Sheet1!$B$2:$B$13');
Workbook.DefinedNames.Add('LocalRate', '$D$2', 0);
Workbook.DefinedNames.FindByName('SalesTotal').Comment := 'Monthly sales range';

See also