HotXLS documentation / API reference

Portable print plans

Keep logical pagination separate from native output: lxPortablePrint builds an immutable print plan from a detached render snapshot, and lxPortableCairo draws its pages as PDF, SVG or PNG on Linux and macOS

The planner works in physical points and complete cell boundaries, preserves merged ranges, repeats row and column titles, and applies disjoint print areas, manual breaks, orientation, margins, centring, scaling and page order without changing the source workbook

Use workbook page setup

CreateXLSPortableWorkbookPrintPlan in lxPortableWorkbookPrint comes with overloads for a borrowed TXLSWorkbook and TXLSXWorkbook; both take SheetIndex, OriginRow, OriginColumn, Snapshot and Defaults

The sheet index and snapshot origin are one-based; the adapter insists on a snapshot from the current workbook generation and a captured rectangle taking in every complete print area and repeated title range

Snapshot identity takes in its generation, whilst the caller supplies the matching sheet and origin; keep the correct sheet context when transporting a snapshot, because the snapshot format encodes neither a workbook nor a worksheet identity

Snapshot := CaptureXLSPortableRenderSnapshot(Owner, 1, 1, 1, 30, 6,
  XLSDefaultPortableRenderLimits, Geometry);
Plan := CreateXLSPortableWorkbookPrintPlan(Workbook, 1, 1, 1,
  Snapshot, XLSDefaultPortablePrintOptions);
Layout := PrepareXLSPortableCairoLayout(Plan, Fonts,
  XLSDefaultPortableCairoOptions);
try
  Files := Layout.Save('/srv/output/report.pdf', xpcfPDF);
  Files := Layout.Save('/srv/output/report.svg', xpcfSVG);
  Files := Layout.Save('/srv/output/report.png', xpcfPNG);
finally
  Layout.Free;
end;

Use the explicit font-backed geometry provider described in direct native workbook capture when capturing on Linux or macOS; pagination itself needs neither Cairo, font files, Excel nor a printer driver

The workbook adapter takes a temporary read lease, reads the existing metadata and hands back detached data; it neither adopts a raw workbook through an owning interface nor keeps a workbook lease in the result

Quoted sheet names, escaped quotes and comma-separated print areas are accepted for the selected worksheet only; references outside the captured rectangle, foreign sheet references, incomplete title ranges and malformed ranges are refused explicitly

Recognised paper sizes are Letter, Tabloid, Ledger, Legal, A3, A4, A5, B4 and B5; an unspecified paper size falls back on Defaults.PageWidthPoints and Defaults.PageHeightPoints, whilst an unrecognised explicit paper size is refused

Header and footer content, printed row/column headings, enabled print gridlines, black-and-white or draft appearance, comment printing and error substitutions are refused for now, because this adapter cannot draw those settings faithfully; Classic workbooks enable print gridlines by default, so switch off PageSetup.PrintGridlines for this supported contract

Scaling mode and native defaults

TXLSXWorksheet.PageFitToPages chooses fit mode independently of its dimensions: assigning FitToWidth or FitToHeight selects fit mode, and assigning PageScale selects percentage scaling

XLSX import preserves sheetPr/pageSetUpPr/@fitToPage together with the OOXML default of one for an omitted fit dimension; export keeps explicit zero dimensions, and XLS/XLSX conversion preserves the selected mode

Percentage scaling disregards stale fit dimensions; fit mode disregards a stored percentage scale, and positive fit dimensions disregard manual breaks; zero on both axes keeps manual breaks at 100% scale, whilst positive limits shrink oversized content without enlarging a small range

Logical pagination depends on the snapshot geometry you supply; printer-driver metrics and Excel PDF export scaling can change the physical output and offer no exact visual equivalence guarantee

Build a detached plan directly

CreateXLSPortablePrintPlan(Snapshot, Areas, Options) takes zero-based inclusive TXLSPortablePrintRanges; an empty Areas array means the whole snapshot, and each TXLSPortablePrintRange carries FirstRow, FirstColumn, LastRow and LastColumn

Begin with XLSDefaultPortablePrintOptions, then set the fields of TXLSPortablePrintOptions listed below

FieldsContract
PageWidthPoints, PageHeightPointsPositive physical paper dimensions in points, default A4
MarginLeftPoints, MarginTopPoints, MarginRightPoints, MarginBottomPointsNonnegative margins that leave a positive printable rectangle, default 36 points
Landscape, CenterHorizontally, CenterVerticallyLandscape swaps the portrait dimensions; centring applies to each page body and its repeated titles
ScalePercent10 through 400, default 100; applies when neither fit dimension is positive
FitToPagesWide, FitToPagesTallNonnegative page limits, zero for an unrestricted axis; positive limits search out a feasible scale between 10% and 100%
TitleFirstRow, TitleLastRow, TitleFirstColumn, TitleLastColumnComplete zero-based inclusive title ranges, or -1 on both endpoints to switch that axis off
RowBreaks, ColumnBreaksTXLSPortablePrintBreaks arrays of strictly ascending unique zero-based positions at which a new page begins; workbook adaptation sorts detached metadata without editing the sheet
OrderTXLSPortablePrintOrder: xppoDownThenOver or xppoOverThenDown
MaxPagesPositive total page limit, default 256 and maximum 100,000
MaxPlanBytesWorking storage, the detached snapshot payload and page records share this positive memory budget, default 64 MiB and maximum 1 GiB
MaxPlanningStepsPositive bounded planning work budget, default 64 Mi steps and maximum 2 Gi steps; going over it raises EXLSPortablePrintBudget

Geometry must be finite; hidden dimensions have zero size, a page break may not split a merge, an area or title may not partially overlap a merge, and an oversized cell or merge is refused rather than being silently cut

Inspect or render the result

IXLSPortablePrintPlan.Snapshot owns a detached immutable render snapshot, PageCount reports the logical page count, and zero-based Pages[Index] hands back a TXLSPortablePrintPage with a detached tile array

Each page exposes AreaIndex, AcrossIndex, DownIndex, its zero-based inclusive Body and Scale, plus PageWidthPoints, PageHeightPoints and Tiles

TXLSPortablePrintTiles holds at most four TXLSPortablePrintTile records covering the repeated corner, title rows, title columns and body; each tile exposes unscaled source SourceLeft, SourceTop, SourceRight, SourceBottom and physical destination DestinationLeft, DestinationTop

The PrepareXLSPortableCairoLayout(Plan, Fonts, Options) overload keeps detached page records, clips and scales scene content for each tile and works from the plan's paper dimensions and margins; raster, font, shaping and drawing budgets keep applying to repeated content

Layout.PageCount matches the plan; PDF produces one multipage file, whilst SVG and PNG produce one file per logical page; the layout's text-line inspection keeps unscaled snapshot coordinates rather than per-page repeated positions

Existing output files are refused, and the Windows native Cairo entry point stays explicitly unsupported; see portable headless output for the dependency, font mapping, scene and output limits