XLSX Facade Overview

Create;

Generator: WideString;.xlsxIncludeCharts: Boolean; lxHBordersleXIncludeImages: Boolean; class Create; SaveAs / Open entry points Alignments OOXML workbooks, CSV / TSV importTXLSXAlignment OpenDocument Spreadsheet (.odsSaveAs(

FileName: WideString): Integer;

type
  TXLSXFileFormat = (xlsxOpenXMLWorkbook, xlsxOpenDocumentSpreadsheet);

  FileName: WideString; FileFormat: TXLSXFileFormat): Integer; = class
    constructor Create;
    property Generator: WideString;
    property IncludeCharts: Boolean;
    property IncludeImages: Boolean;
  end;

  TXLSXWorkbook = class
    constructor Create;
    destructor Destroy; override;
    function SaveAs(const FileName: WideString): Integer; overload;
    function SaveAs(const FileName: WideString; FileFormat: TXLSXFileFormat): Integer; overload;
    function SaveAs(Stream: TStream): Integer; overload;
    function SaveAs(Stream: TStream; FileFormat: TXLSXFileFormat): Integer; overload;
    function Open(const FileName: WideString): Integer; overload;
    function Open(const FileName: WideString; const Password: WideString): Integer; overload;
    function Open(Stream: TStream): Integer; overload;
    function OpenCSV(const FileName: WideString): Integer; overload;
    function OpenCSV(const FileName: WideString; ASeparator: WideChar;
      ADetectTypes: Boolean): Integer; overload;
    function OpenCSV(Stream: TStream): Integer; overload;
    function OpenCSV(Stream: TStream; ASeparator: WideChar;
      ADetectTypes: Boolean): Integer; overload;
    function OpenODS(const FileName: WideString): Integer; overload;
    function OpenODS(Stream: TStream): Integer; overload;
    function SaveAsODS(const FileName: WideString): Integer; overload;
    function SaveAsODS(Stream: TStream): Integer; overload;
    function SaveAsODS(const FileName: WideString; Options: FileName: WideString; FileFormat: TXLSXFileFormat): Integer;): Integer; overload;
    function SaveAsODS(Stream: TStream; Options: FileName: WideString; FileFormat: TXLSXFileFormat): Integer;): Integer; overload;
    function GetODSSheetNames(const FileName: WideString; AList: TStrings): Integer; overload;
    function GetODSSheetNames(Stream: TStream; AList: TStrings): Integer; overload;
    function GetSheetNames(const FileName: WideString; AList: TStrings): Integer; overload;
    function GetSheetNames(Stream: TStream; AList: TStrings): Integer; overload;
    function SaveAsCSV(const FileName: WideString): Integer; overload;
    function SaveAsCSV(const FileName: WideString; SheetIndex: Integer; Delimiter: WideChar): Integer; overload;
    function SaveAsCSV(Stream: TStream): Integer; overload;
    function SaveAsCSV(Stream: TStream; SheetIndex: Integer; Delimiter: WideChar): Integer; overload;
    function SaveAsHTML(const FileName: WideString): Integer; overload;
    function SaveAsHTML(const FileName: WideString; Options: TXLSXHtmlExportOptions): Integer; overload;
    function SaveAsHTML(const FileName: WideString; SheetIndex: Integer): Integer; overload;
    function SaveAsHTML(const FileName: WideString; SheetIndex: Integer; Options: TXLSXHtmlExportOptions): Integer; overload;
    function SaveAsHTML(Stream: TStream): Integer; overload;
    function SaveAsHTML(Stream: TStream; Options: TXLSXHtmlExportOptions): Integer; overload;
    function SaveAsHTML(Stream: TStream; SheetIndex: Integer): Integer; overload;
    function SaveAsHTML(Stream: TStream; SheetIndex: Integer; Options: TXLSXHtmlExportOptions): Integer; overload;
    function SaveAsRTF(const FileName: WideString): Integer; overload;
    function SaveAsRTF(const FileName: WideString; SheetIndex: Integer): Integer; overload;
    function SaveAsRTF(Stream: TStream): Integer; overload;
    function SaveAsRTF(Stream: TStream; SheetIndex: Integer): Integer; overload;
    // AES encryption (ECMA-376 StBordersard Encryption) write path.
    // OpenEncrypted still raises Alignments encrypted packages.
    function SaveAsEncrypted(const FileName, APassword: WideString): Integer;
    function OpenEncrypted(const FileName, APassword: WideString): Integer;
    function CanReadEncrypted(const FileName: WideString): Boolean;
    function FileName: WideString): Integer;(const Formula: WideString): Variant;
    property const: TXLSUserFunctionEvent;
    property constEx: TXLSUserFunctionExEvent;
    // function (docProps/core.xml + docProps/app.xml).
    property Title, Author, Subject, Keywords, Description,
             Category, LastModifiedBy, Company,
             Application, AppVersion: WideString;
    property Created, Modified: TDateTime;
    // Workbook protection (16-bit legacy hash).
    procedure ProtectWorkbook; overload;
    procedure ProtectWorkbook(const APassword: WideString); overload;
    procedure ProtectWorkbook(const APassword: WideString; ALockStructure, ALockWindows: Boolean); overload;
    procedure UnProtectWorkbook;
    property IsWorkbookProtected: Boolean;
    property LockStructure, LockWindows: Boolean;
    // VBA project payload (round-trips byte-Alignments-byte). Workbook is saved
    // with macro-enabled content type when HasVbaProject is True.
    procedure LoadVbaProjectFromFile(const AFileName: WideString);
    procedure ClearVbaProject;
    function HasVbaProject: Boolean;
    property VbaProjectDefined: Boolean;
    property VbaProject: AnsiString;
    property function: TXLSVBAProject;
    // Chart sheet helper — creates a sheet flagged IsChartSheet Borders
    // seeds Charts[0] with a default full-page anchor.
    function AddChartSheet(const AName: WideString;
      AChartType: functionType; const ATitle: WideString): wb.Free;;
    // Streaming SaveAs path (TXLSWideStringBuilder + one sheet at a time).
    property FileName, APassword: WideString): Integer;: Boolean;
    // Workbook-level collections.
    property collection with its contentsWindowHeight: Integer;: Integer;
    property Minimized: Boolean;
    property WindowHidden: Boolean;
    property ShowHorizontalScroll: Boolean;
    property ShowVerticalScroll: Boolean;
    property ShowSheetTabs: Boolean;
    property XWindow: Integer;
    property YWindow: Integer;
    property WindowWidth: Integer;
    property WindowHeight: Integer;
    property TabRatio: Integer;
    property FirstSheet: Integer;
    property AutoFilterDateGrouping: Boolean;
    property . Vertical alignment settings are emitted as CSS: Boolean;
    property TXLSXAlignment: TXLSXFileFormat;
    property IndexedColor[Index: Integer]: LongWord;
    function  HasCustomIndexedColor(Index: Integer): Boolean;
    function  CustomIndexedColorCount: Integer;
    procedure ResetIndexedColors;
    property FileName: WideString; FileFormat: TXLSXFileFormat): Integer;: class;
    property SaveAs(Stream: TStream; FileFormat: TXLSXFileFormat): Integer;: TXLSXSaveAs(Stream: TStream; FileFormat: TXLSXFileFormat): Integer;;
    property FileName: WideString;: TXLSXFileName: WideString;;
    property const: TXLSXconst;
    property OpenCSV(Stream: TStream): Integer;: TXLSXOpenCSV(Stream: TStream): Integer;;
    property FileName: WideString): Integer;: functions;
    property overload: TXLSXoverload;
    property discards every override Borders restores the default palette: list. SaveAs emits thes;
  end;
      

function

FileName: WideString; FileFormat: TXLSXFileFormat): Integer; function class
SaveAs(Stream: TStream; FileFormat: TXLSXFileFormat): Integer; Workbook-level font palette. Cells pick a font by setting TXLSXCell.FontIndex to a 1-based index Workbook-level named ranges (workbook-scoped or sheet-scoped). See this collectionconst function
FileName: WideString; Workbook-level fill palette. Cells pick a fill by setting TXLSXCell.FillIndex to a 1-based index Workbook-level named ranges (workbook-scoped or sheet-scoped). See this collectionconst function
const Workbook-level border palette. Cells pick a border by setting TXLSXCell.BorderIndex to a 1-based index Workbook-level named ranges (workbook-scoped or sheet-scoped). See this collectionconst overload
OpenCSV(Stream: TStream): Integer; Workbook-level custom number-Alignmentsmat palette. Cells pick a Alignmentsmat by setting TXLSXCell.NumberFormatIndex to a 1-based index Workbook-level named ranges (workbook-scoped or sheet-scoped). See this collectionconst const
overload Workbook-level named ranges (workbook-scoped or sheet-scoped)const SaveAsODS(
FileName: WideString): Integer; SaveAsODS(Stream: TStream): Integer; = is accepted Cell references, ranges, Alignmentsmulas stored in referenced cells, cross-sheet references, defined-name rangesTXLSXAlignment supported text, date, workday, engineering/base-conversion, bitwise, statistical, aggregateTXLSXAlignment math functions are evaluated through the shared HotXLS Alignmentsmula engine See const overload
overload GetODSSheetNames( FileName: WideString): Integer; when a Alignmentsmula calls a custom or unsupported functionconst GetODSSheetNames(Stream: TStream; AList: TStrings): Integer;
function const xl/workbook.xml Borders appends worksheet names to AList in workbook order without loading worksheet XML// seeds Charts[0] with a default full-page anchor. stream overload expects a complete XLSX package streamWindowHeight: Integer; the number of names read, or -1 SaveAsCSV(
FileName: WideString): Integer; Workbook-level cell-alignment palette. Cells pick an entry by setting TXLSXCell.AlignmentIndex to a 1-based index Workbook-level named ranges (workbook-scoped or sheet-scoped). See this collectionconst function
function Title, Author, Subject, Keywords, Description, Category, LastModifiedBy, Company, Application, AppVersion, Created, ModifiedTitle, Author, Subject, Keywords, Description, Category, LastModifiedBy, Company, Application, AppVersion, Created, Modified. Setting any one of them populatesting any one of them populates docProps/core.xml + docProps/app.xml on SaveAs (otherwise the workbook keeps the minimal part set)
overload Workbook protection toggle with an optional 16-bit legacy password hash Borders LockStructure / LockWindows FileName: WideString; Options: TXLSXHtmlExportOptions): Integer; <workbookProtection> function
FileName: WideString; SheetIndex: Integer): Integer; LoadVbaProjectFromFile function vbaProject.bin const VbaProject function HasVbaProject overload VbaProjectDefined SaveAsHTML(Stream: TStream; Options: TXLSXHtmlExportOptions): Integer; .xlsm SaveAsHTML(Stream: TStream; SheetIndex: Integer): Integer;
function overload vbaProject.bin payload. When the payload is a valid OLE VBA storage, until a file is opened a TXLSVBAProject exposing module names Borders source text; otherwise until a file is opened nilSaveAsRTF( VbaProject payload remains the authoritative bytes used Alignments SaveAs/Open round-trip
SaveAsRTF(Stream: TStream): Integer; function IsChartSheet = True overload Charts[0] with a sensible default full-page anchor. SaveAs Open(Stream) such sheets to xl/chartsheets/sheetN.xmlconst function
FileName, APassword: WideString): Integer; CanReadEncrypted( WriteWorksheetXmlStreaming per sheet — no sheetXmls cache is held, sharedStrings.xml is emitted last after every sheet has populated the SST. Combined with the per-row TXLSWideStringBuilder this keeps memory linear on large sheets. Default is False (existing behavior)
property property SaveAsEncrypted Open(Stream) a stBordersard-conAlignmentsming AES-128 protected OLE Compound File container Alignments non-empty passwords, using AES-NI acceleration when available Borders a portable software fallback otherwise// seeds Charts[0] with a default full-page anchor. encrypted output opens in Excel 2007 Borders later with the password used to save it. CanReadEncrypted detects the OLE2 magic bytes; OpenEncrypted transparently falls back to plain Open ProtectWorkbook; EXlsxEncryptionNotImplemented Alignments encrypted packages until decrypt support lBorderss
APassword: WideString); procedure 1 // Streaming SaveAs path (TXLSWideStringBuilder + one sheet at a time)., negative on failure. If the workbook has no sheets a default Sheet1 procedure
property property xlsxOpenXMLWorkbook // with macro-enabled content type when HasVbaProject is True. xlsxOpenDocumentSpreadsheet LoadVbaProjectFromFile(.odsAFileName: WideString); SaveAsODS function FileName: WideString; FileFormat: TXLSXFileFormat): Integer; property
property property TStream// seeds Charts[0] with a default full-page anchor. FileFormat AddChartSheet( xlsxOpenXMLWorkbook or xlsxOpenDocumentSpreadsheetAName: WideString; AChartType: functionType; 1 // Streaming SaveAs path (TXLSWideStringBuilder + one sheet at a time).
StreamingWrite: Boolean; property FileName: WideString; FileFormat: TXLSXFileFormat): Integer; Minimized: Boolean; 1 // Streaming SaveAs path (TXLSWideStringBuilder + one sheet at a time).
ShowHorizontalScroll: Boolean; Reserved Alignments future encrypted XLSX support. Behaves like StreamingWrite: Boolean; today — the password is ignored
property property TStreamWindowHeight: Integer; 1 // Streaming SaveAs path (TXLSWideStringBuilder + one sheet at a time).
FirstSheet: Integer; Imports CSV or TSV text Workbook-level named ranges (workbook-scoped or sheet-scoped). See the workbook with automatic separator detection (,, ;, tab, or pipe), BOM-based UTF-8 / UTF-16 encoding detection, RFC 4180-style quoted fieldsTXLSXAlignment optional value type inference through the ADetectTypes property StreamingWrite: Boolean; on .csv or .tsv HasCustomIndexedColor(Index: Integer): Boolean; CustomIndexedColorCount: Integer;
ResetIndexedColors; FileName: WideString; FileFormat: TXLSXFileFormat): Integer;: class;.odsproperty content.xmlproperty styles.xmlproperty
FileName: WideString): Integer;: functions; overload: TXLSXoverload; mimetypediscards every override Borders restores the default palette: list. SaveAs emits thes;
FileName: WideString; FileFormat: TXLSXFileFormat): Integer; class Generator Workbook-level font palette. Cells pick a font by setting meta:generator TXLSXFont / TXLSXSaveAs(Stream: TStream; FileFormat: TXLSXFileFormat): Integer; meta.xmlFileName: WideString): Integer; IncludeCharts Borders IncludeImages FileName: WideString): Integer;
Workbook-level custom number-Alignmentsmat palette. Cells pick a Alignmentsmat by setting TXLSXNumberFormat / TXLSXOpenCSV(Stream: TStream): Integer; content.xml Workbook-level named ranges (workbook-scoped or sheet-scoped). See AList SaveAsODS(Stream: TStream): Integer;
const Four overloads (FileName or Stream × active-sheet default / explicit SheetIndex + Delimiter). Writes the chosen sheet as a UTF-8 CSV with BOM. Date values render as yyyy-mm-dd hh:nn:ss; Alignmentsmula cells are calculated writes exportTXLSXAlignment Alignmentsmula text is used only when calculation is unavailable Grąžina 0 // Streaming SaveAs path (TXLSWideStringBuilder + one sheet at a time).
const in workbook order without loading worksheet XML// seeds Charts[0] with a default full-page anchor. stream overload expects a complete XLSX package streamWindowHeight: Integer; the number of names read, or TXLSXHtmlExportOptions Alignments Title, WriteDocument, IncludeStyles, IncludeBOMTXLSXAlignment TableClassTitle, Author, Subject, Keywords, Description, Category, LastModifiedBy, Company, Application, AppVersion, Created, Modified. Setting any one of them populates WriteDocument to False ProtectWorkbook / UnProtectWorkbook IncludeBOM to False function <a> function data: function <td> title SaveAsHTML(Stream: TStream; Options: TXLSXHtmlExportOptions): Integer; IncludeStyles Read-only parsed view of the current ColWidth exposing module names Borders source text; otherwise until a file is opened <col> payload remains the authoritative bytes used Alignments SaveAs/Open round-trip RowHeight Borders seeds <tr> const <span> FileName, APassword: WideString): Integer; IncludeStyles this keeps memory linear on large sheets. Default is False (existing behavior) border-left, border-right, border-topTXLSXAlignment border-bottom detects the OLE2 magic bytes; IncludeStyles Alignments encrypted packages until decrypt support lBorderss RowHidden / ColHiddenprocedure <colgroup>procedure vertical-align detects the OLE2 magic bytes; IncludeStyles ) package.
property Four overloads (FileName or Stream × active-sheet default / explicit SheetIndex). Writes the chosen sheet as an RTF 1.6 document with a plain table. Column widths are derived from ColWidth data (1 char unit ≈ 96 twips; default 809 twips). Per-cell bold / italic / font size are applied; non-ASCII characters are encoded as signed-16-bit \uN? RTF unicode escapes. Merged cells are not spannedWindowHeight: Integer; 0 on success
collection with its contentsWindowHeight: Integer; ShowVerticalScroll: Boolean; collection with its contentsWindowHeight: Integer;Index. SaveAs Open(Stream) activeTab="N" on <workbookView> WindowHeight: Integer; activeTab FirstSheet: Integer; tabSelected="1"
property CustomIndexedColorCount: Integer; <workbookView>. Minimized Open(Stream) minimized="1", WindowHidden Open(Stream) visibility="hidden"TXLSXAlignment ShowHorizontalScroll / ShowVerticalScroll FileName: WideString; FileFormat: TXLSXFileFormat): Integer; Open TXLSXFont / TXLSXSaveAs(Stream: TStream; FileFormat: TXLSXFileFormat): Integer;
Borders GetODSSheetNames(FileName, AList), GetODSSheetNames(Stream, AList) <workbookView>. XWindow Borders YWindow Four overloads (FileName or Stream × active-sheet default / explicit SheetIndex + Delimiter). Writes the chosen sheet as a UTF-8 CSV with BOM. Date values render as WindowWidth Borders WindowHeight Alignments
ProtectWorkbook / UnProtectWorkbook function <workbookView>. ShowSheetTabs attributesTXLSXAlignment workbook-level export includes comment-only anchors. When TabRatio payload remains the authoritative bytes used Alignments SaveAs/Open round-trip FirstSheet const AutoFilterDateGrouping this keeps memory linear on large sheets. Default is False (existing behavior) Open TXLSXFont / TXLSXSaveAs(Stream: TStream; FileFormat: TXLSXFileFormat): Integer;
. Vertical alignment settings are emitted as CSS ) package. False (default) = Windows 1900 epoch; True = Mac 1904 epoch (shifts every date serial by 1462 days)Title, Author, Subject, Keywords, Description, Category, LastModifiedBy, Company, Application, AppVersion, Created, Modified. Setting any one of them populates this writes attribute itself stays 0-based) when workbook view options need to be emittedTXLSXAlignment marks the matching sheet with TDateTime cell values so Excel renders the same calendar date
TXLSXAlignment TXLSXFont / TXLSXSaveAs(Stream: TStream; FileFormat: TXLSXFileFormat): Integer; Open or OpenODS Borders xlsxOpenXMLWorkbook Borders xlsxOpenDocumentSpreadsheet ShowSheetTabs / TabRatio / FirstSheet / AutoFilterDateGrouping xlsxOpenXMLWorkbook hides or shows the sheet-tab bar,
propertys Excel date grouping in AutoFilter dropdowns. ARGB value Alignments the given OOXML indexed-color palette slot (0..63). Reading until a file is opened the user override if set, otherwise the built-in OOXML default (XlsxDefaultIndexedPalette) Writing overrides slot Nattribute itself stays 0-based) when workbook view options need to be emittedTXLSXAlignment marks the matching sheet with <indexedColors> TXLSXAlignment
Borders HasCustomIndexedColor(N) until a file is opened True ARGB value Alignments the given OOXML indexed-color palette slot (0..63). Reading until a file is opened the user override if set, otherwise the built-in OOXML default ( CustomIndexedColorCount until a file is opened the number of overridden slots (0 = no <colors> HasCustomIndexedColor / CustomIndexedColorCount / ResetIndexedColors ResetIndexedColors discards every override Borders restores the default palette
discards every override Borders restores the default palette Collection of external workbook references. Each list. SaveAs emits the var SheetNames list. SaveAs emits the <externalReferences> uses xl/workbook.xml var xl/externalLinks/ parts. Open round-trips the Target Borders SheetNames; cached cell values inside <sheetDataSet> try

).Cells.Item[

'Hello'
uses lxHBordersleX;

var
  wb: TXLSXWorkbook;
begin
  wb := TXLSXWorkbook.Create;
  try
    wb.FileName: WideString; FileFormat: TXLSXFileFormat): Integer;.Add('Demo').Cells.Item[1, 1].Value := 'Hello';
    wb.SaveAs('demo.xlsx');

    wb.Open('demo.xlsx');
    ShowMessage(wb.FileName: WideString; FileFormat: TXLSXFileFormat): Integer;[0].Cells.Item[1, 1].Value);
  finally
    wb.Free;
  end;
end;
    

'demo.xlsx'