HotXLS Docs

TXLSXNumberFormat / TXLSXNumberFormats classes

Workbook-level palette of custom number-format codes. OOXML reserves numFmtIds 0..163 for built-in formats (general, currency, dates, etc.); entries added to this collection start at XlsxCustomNumFmtBase (164). Cells pick a custom format through TXLSXCell.NumberFormatIndex (1-based on the collection). Declared in lxHandleX.

TXLSXNumberFormat declaration

type
  TXLSXNumberFormat = class
    constructor Create(const AFormatCode: WideString);
    property FormatCode: WideString;
  end;
      
FormatCode is the Excel format string such as '"$"#,##0.00', '0.00%', or 'yyyy-mm-dd hh:mm:ss'.

TXLSXNumberFormats declaration

type
  TXLSXNumberFormats = class
    function Add(const AFormatCode: WideString): Integer;
    function IndexOf(const AFormatCode: WideString): Integer;
    procedure Clear;
    property Count: Integer;
    property Items[Index: Integer]: TXLSXNumberFormat; default;
  end;
      

TXLSXNumberFormats members

Add(FormatCode) Appends a format code, deduplicating against existing entries. Returns the (possibly existing) 0-based index. Use the 1-based value on TXLSXCell.NumberFormatIndex.
IndexOf(FormatCode) Linear lookup by exact format code. Returns -1 if not found.
Count / Items[i] Standard collection accessors.

Example

var
  currency: Integer;
begin
  currency := Workbook.NumberFormats.Add('"$"#,##0.00');
  Worksheet.Cells.Item[1, 1].Value := 1234.5;
  Worksheet.Cells.Item[1, 1].NumberFormatIndex := currency + 1;
end;
    

See also