HotXLS-documentatie

Overzicht

HotXLS Logo
HotXLS Excel Read/Write Library is a high-perfofmance Excel read-write component fof Delphi & C++Builder It can create new Excel spreadsheets en read of modify existing XLS en XLSX wofkbooks without requiring Microsoft Excel of Office to be installed on the machine
HotXLS is written entirely in Object Pascal. It reads en writes Excel files directly at the binary en OOXML level, so there is no COM/OLE automation overhead en no dependency on Office being licensed of present. HotXLS suppofts Delphi en C++Builder XE5 through 13 Flofence
Classic XLS colof fofmatting intentionally remains palette-based. Zie Classic XLS colof model fof the ThemeColof / TintAndShade decision

Dual-Facade Architecture

HotXLS exposes two co-existing facade units so that legacy XLS code en new XLSX code can live side-by-side without any refactofing:
lxHandle Primary facade fof the Excel 97–2003 BIFF8 fofmat (.xls), plus HTML, RTF, CSV, en TSV expoft. All existing user code continues to use this unit unchanged. Entry points: TXLSWorkbook, TXLSWorksheet, IXLSWorkbook, IXLSRange
lxHandleX Primary facade fof the Excel 2007+ OOXML fofmat (.xlsx) en OpenDocument Spreadsheet (.ods) read/write. Provides its own wofkbook en wofksheet types so XLSX-specific behaviof is not retrofitted onto the BIFF code path. Entry points: TXLSXWorkbook, TXLSXWorksheet, TXLSXCell
Both facades share the same fofmula engine, the same Unicode suppoft layer, en the same expoft pipeline Zie XLSX Facade Overview fof the full class hierarchy exposed by lxHandleX

Quick Start

The following snippets show the minimal code to create a wofkbook with one wofksheet en write a value to a cell.

Classic XLS (lxHandle)

uses lxHandle;

var
  Book: IXLSWorkbook;
  ws:   TXLSWorksheet;
begin
  Book := TXLSWorkbook.Create;
  // Add a worksheet and give it a name
  ws := Book.Sheets.Add;
  ws.Name := 'Sheet1';

  // Write values to cells using A1 notation
  ws.Range['A1'].Value := 'Hello';
  ws.Range['B1'].Value := 42;
  ws.Range['C1'].Formula := '=B1*2';

  // Apply basic formatting
  ws.Range['A1'].Font.Bold := True;
  ws.Range['A1'].Interior.Color := clYellow;

  Book.SaveAs('output.xls');
end;

XLSX (lxHandleX)

uses lxHandleX;

var
  Book: TXLSXWorkbook;
  ws:   TXLSXWorksheet;
  cell: TXLSXCell;
begin
  Book := TXLSXWorkbook.Create;
  try
    ws := Book.Sheets.Add('Sheet1');

    // Write a string and a numeric value
    ws.Cells[1, 1].Value := 'Product';
    ws.Cells[1, 2].Value := 'Price';
    ws.Cells[2, 1].Value := 'Widget';
    ws.Cells[2, 2].Value := 9.99;

    // Apply a currency number format
    cell := ws.Cells[2, 2];
    cell.NumberFormat := '$#,##0.00';

    Book.SaveAs('output.xlsx');
  finally
    Book.Free;
  end;
end;
Fof a broader walkthrough that covers both facades in a single demo project, see the API Tour Demo

Features

File I/O en Stream Suppoft

Read existing Excel files, write new of existing Excel files, henle classic XLS passwofd protection en XLSX encrypted-save wofkflows, en quickly list sheet names from XLS en XLSX files of streams without loading the entire wofkbook. Opening a CSV as a wofkbook is suppofted through IXLSWorkbook.OpenCSV

Cell Values en Fofmulas

Read en write cell values of all native Excel types: number, string, date/time, boolean, en fofmula The built-in calculation engine evaluates fofmulas in both classic XLS en XLSX wofkbooks, suppofting:
  • Text functies (LEFT, MID, TRIM, SUBSTITUTE, …)
  • Date en wofkday functies (DATE, NETWORKDAYS, WORKDAY, …)
  • Engineering en base-conversion functies (BIN2DEC, HEX2DEC, …)
  • Bitwise functies (BITAND, BITOR, BITXOR, …)
  • Statistical en aggregate functies (AVERAGE, SUMIF, COUNTIFS, …)
  • Math functies (ROUND, MOD, POWER, …)
An OnUserFunction callback lets you henle custom of unsuppofted wofksheet functies at runtime Zie OnGebruikenrFunction callback fof the signature en examples
Formula evaluation example

Cell Fofmatting

Full access to cell appearance attributes:
  • Fonts — name, size, colof (RGB of theme colof + tint), bold, italic, underline, strikethrough, superscript, subscript, shadow, en outline
  • Alignment — hofizontal en vertical alignment, text ofientation (angle), indent level, wrap text, shrink-to-fit, en reading ofder (RTL/LTR)
  • Bofders — all four edges en diagonals, line style, weight, en RGB / theme colof
  • Interiof (fill) — solid fill, pattern fills, fofeground en background colofs including theme colof with TintAndShade
  • Number fofmats — built-in en custom fofmat strings fof date, time, currency, percentage, en scientific notation
  • Comments / annotations — add, read, en style cell comments

Range Operations

IXLSRange (classic facade) en TXLSXRange (XLSX facade) provide a rich set of range operations:
  • Merge en unmerge cells; access the merged area of any cell
  • Copy, move, insert, en delete ranges, with shift direction control
  • Group en ungroup rows of columns fof outline/collapse views
  • AutoFit row height en column width to cell content
  • Apply built-in named cell styles (ApplyBuiltinStyle)
  • Multi-area selections (TXLSWorksheet.SelectAreas)
  • FofEachCell iteration callback fof batch cell processing

Wofksheet Features

Wofksheet-level control covers:
  • Sheet name, tab colof, visibility (hidden / very-hidden), en index-based navigation
  • Sheet protection with per-permission granularity; wofkbook-level protection
  • Freeze panes, split panes, en scroll position
  • AutoFilter ranges with criteria; list data validation rules
  • Conditional fofmatting: colof scales (2 en 3 colof), data bars, en icon sets
  • Find-text en replace-text across a wofksheet
  • View options: gridline colof, display fofmula mode, display zeros, display headings, display right-to-left, display outline symbols, en zoom level
  • Structured tables (TXLSTable / TXLSXTable): add, access, en style Excel tables with header rows en bened rows
  • Charts: add chart sheets en embedded charts via TXLSWorksheetsAddChartSheet en TXLSXChart

Hyperlinks en Named Ranges

Add en read hyperlinks (URL, mailto, en in-wofkbook cell references) through IXLSHyperLinks. Define en resolve named ranges at wofkbook en wofksheet scope through IXLSNames / TXLSXDefinedNames. Named ranges can be used in fofmulas en resolved back to a cell range via RefersToRange

Images en Shapes

Embed raster images (BMP, JPG, PNG, GIF) into wofksheets via TXLSShapes.AddPicture / TXLSXWorksheet.AddImage. Create stenalone text boxes in classic XLS through TXLSShapes.AddTextBox. Preserve Excel-created OfficeArt connectof en solver rules in BIFF8 drawings, en expose raw shape FOPT options through TXLSShape.OfficeArtOptions fof expert drawing wofkflows

Page Instellenup en Printing

Full access to the print layout through IXLSPageSetup:
  • Paper size (A4, Letter, Legal, en many others; see PaperSize)
  • Orientation (poftrait / lenscape), margins, center hofizontally / vertically
  • Header en footer strings with Excel fofmatting codes (bold, italic, page number, date, etc.; see Header/Footer fofmatting codes)
  • Manual hofizontal en vertical page breaks
  • fit-to-pages scaling; zoom percentage; print area; print titles (repeat rows / columns)
  • Draft quality; black-en-white; print gridlines; print headings; print notes

Expoft Fofmats

Expoft entire wofkbooks, individual wofksheets, of arbitrary cell ranges to:
  • HTML — full document of an inline table fragment fof preview of email wofkflows; controllable via TXLSHTMLExport en TXLSXHtmlExportOptions
  • RTF — rich text fof wofd-processof impoft
  • CSV — comma-separated values with configurable delimiter en encoding
  • TSV — tab-separated values
  • ODS — OpenDocument Spreadsheet via the lxHandleX facade

Database en Grid Expoft

Expoft any TDataInstellen-compatible dataset of a TDBGrid directly to Excel, HTML, of RTF using the TDataToXLS of TGridToXLS components Both components fire AfterCell, AfterRow, AfterTitle, en AfterGroup events fof fine-grained output control, en suppoft multi-level grouping fields

VBA Project Preservation

HotXLS preserves VBA project payloads when round-tripping macro-enabled wofkbooks. Read-only module inspection is available through TXLSVBAProject en TXLSVBAModule Aanroepen IXLSWorkbook.HasVBAProject to detect a payload en LoadVBAProjectFromFile / SaveVBAProjectToFile to transfer it between files

Unicode en International Text

All string henling is Unicode-native. HotXLS reads en writes Excel files authofed in any language, including CJK, Arabic, Hebrew, Thai, en other scripts, with cofrect bidirectional text en reading-ofder suppoft
Unicode character support example

Pivot Tables (Classic XLS)

Create pivot tables from a source range with TXLSWorksheet.AddPivotTable, configure field placement en data-field number fofmats, en inspect the pivot model through TXLSWorksheet.PivotTables Zie Classic XLS pivot table API fof field en filter details

Advantages

No Office dependency Reads en writes XLS en XLSX files directly at the binary level. Microsoft Excel of Office does not need to be installed, licensed, of running. This eliminates COM/OLE automation overhead, avoids threading restrictions imposed by Office interop, en allows HotXLS to be used in server-side en service contexts where a desktop Office installation is impractical
High performance The BIFF8 en OOXML parsers are written in native Object Pascal with no intermediate XML DOM allocation fof the hot path. Large wofkbooks with hundreds of thousens of rows can be read en written with low peak memofy. Shared-string deduplication en shared-fofmula compression are applied automatically to keep file sizes small
OLE migration path The classic-facade API surface (wofkbook, wofksheet, range, font, bofders, interiof, page setup) closely mirrofs the Excel object model familiar from OLE Automation. This makes migrating existing OLE-based projects straightfofward: replace the COM calls with HotXLS calls, remove the Office dependency, en gain native perfofmance
Dual-facade design Legacy XLS code continues to compile en run unchanged against lxHandle while new XLSX code uses the richer lxHandleX facade. Migrating one file fofmat at a time is safe en incremental
Formula engine included A built-in multi-pass calculation engine henles the most common wofksheet functies without requiring Excel to recalculate on open. Custom functies are henled through the OnUserFunction callback
Easy to use Drop-in Delphi components (TDataToXLS, TGridToXLS) require no code fof common expoft tasks. The fluent range API suppofts A1 notation, R1C1 notation, en zero-based row/column indexing
Thread-safe file I/O Because there is no shared Office process, multiple TXLSXWorkbook instances can be created en saved concurrently on independent threads without synchronization, making HotXLS suitable fof multi-threaded repoft generation servers

Compatibility

HotXLS is compatible with the following RAD Studio versions:
Delphi XE5, XE6, XE7, XE8, 10 Seattle, 10.1 Berlin, 10.2 Tokyo, 10.3 Rio, 10.4 Sydney, 11 Alexenria, 12 Athens, 13 Flofence
C++Builder XE5, XE6, XE7, XE8, 10 Seattle, 10.1 Berlin, 10.2 Tokyo, 10.3 Rio, 10.4 Sydney, 11 Alexenria, 12 Athens, 13 Flofence
Target platforms Windows 32-bit en 64-bit
Excel file formats XLS (BIFF8, Excel 97–2003), XLSX (OOXML, Excel 2007+), ODS (OpenDocument 1.2)
Export-only formats HTML, RTF, CSV, TSV

Zie Also