Direct reader and writer API
TXLSDirectReader and TXLSDirectWriter process XLSX packages without holding a complete worksheet grid in memory, so API calls that describe a sheet must be made before or during the corresponding streaming phase
Writer lifecycle and cell values
TXLSDirectWriter.BeginFile or BeginStream starts a package, sheet methods define one worksheet at a time, and Finish commits the final package
| Scalar cells | WriteString, WriteRichString, WriteNumber, WriteBoolean, WriteDateTime, and WriteError |
| Formula cells | WriteFormula, WriteFormulaNumber, WriteFormulaString, WriteFormulaBoolean, WriteFormulaDateTime, and WriteFormulaError accept caller-supplied cached results |
| Shared strings | UseSharedStrings enables package-level string deduplication |
| Statistics | CellCount reports the number of emitted cells |
| Panes | FreezePanes(ColSplit, RowSplit) writes a frozen split at the given one-based column and row |
Rows and columns are one-based in the public writer surface and must be supplied in forward worksheet order
Reusable styles
AddCellStyle registers an immutable package-level style handle and CloneCellStyle derives a new handle without retaining worksheet rows
Defined names and hyperlinks
AddDefinedName, AddLocalDefinedName, AddDefinedRange, and AddLocalDefinedRange add workbook or sheet-local names before package finalization
AddHyperlink, AddHyperlinkRange, AddInternalHyperlink, and AddInternalHyperlinkRange emit external relationships or internal sheet locations for one cell or a range
Data validation
AddDataValidation and AddDataValidationSqRef expose the complete rule surface, while AddListValidation, AddWholeNumberValidation, AddDecimalValidation, AddDateValidation, AddTimeValidation, AddTextLengthValidation, and AddCustomValidation provide typed helpers
Conditional formatting
AddConditionalFormat, AddConditionalFormatExpression, AddConditionalFormatContainsText, AddConditionalFormatNotContainsText, AddConditionalFormatBeginsWith, AddConditionalFormatEndsWith, AddConditionalFormatTop10, AddConditionalFormatAboveAverage, AddConditionalFormatDuplicateValues, AddConditionalFormatUniqueValues, AddConditionalFormatContainsBlanks, AddConditionalFormatNotContainsBlanks, AddConditionalFormatContainsErrors, and AddConditionalFormatNotContainsErrors add scalar rules
AddConditionalFormatDataBar, AddConditionalFormatColorScale2, AddConditionalFormatColorScale3, and AddConditionalFormatIconSet add visual rules; ClearConditionalFormats removes pending rules for the current sheet
AutoFilter and tables
AddAutoFilterValue, AddAutoFilterDateGroup, and AddAutoFilterSortCondition configure the worksheet filter
AddTable creates a table part, and AddTableFilterValue, AddTableFilterDateGroup, and AddTableSortCondition configure its filter and sort state
Protection and page breaks
ProtectSheet, UnprotectSheet, AddProtectedRange, and ClearProtectedRanges configure worksheet protection; ProtectWorkbook and UnprotectWorkbook configure workbook structure and window locks
AddHorizontalPageBreak and AddVerticalPageBreak emit manual page breaks for the current worksheet
Direct reader storage diagnostics
TXLSDirectReader.SharedStringMemoryLimit bounds decoded shared-string memory, SharedStringsOnDisk reports migration to temporary indexed storage, SharedStringCount reports the loaded entry count, and ParallelDiag exposes bounded parallel-parser diagnostics
Reader projection and formula state
FirstRow, LastRow, IncludeColumn, and ClearColumnProjection push row and one-based column selection into the worksheet parser before value, formula, or rich-text allocation
IncludeFormulaText defaults to true; disabling it keeps cached values, coordinates, styles, and HasFormula while FormulaTextAvailable becomes false and Formula remains empty
Row cursor
TXLSRowCursor.Open accepts XLS, XLSX, XLSM, ODS, CSV, and TSV files or streams; ZIP auto-detection distinguishes ODS packages from Open XML workbooks before a sheet is opened
SelectSheet and SelectSheetByName choose a worksheet; SheetCount, SheetNames, SheetIndex, RowIndex, and Eof expose traversal state, while SharedStringMemoryLimit applies the same bounded shared-string policy as the direct reader
FirstRow, LastRow, IncludeColumn, and ClearColumnProjection use the same one-based filters across all cursor formats; pass options cannot change between FindFirst and EOF but become mutable again after EOF, sheet selection, or close
Each TXLSRowCursorCell reports HasFormula independently from FormulaTextAvailable; classic XLS exposes formula presence and cached results without claiming unavailable token text, while IncludeFormulaText can suppress XLSX and ODS formula text before accumulation
ODS traversal holds one physical row template, clips repeated row blocks to the requested interval, jumps directly between selected columns inside repeated spans, advances across covered cells without returning them as values, and reports invalid or grid-limited repeat counts through OnSkippedRecord
State distinguishes xrcsClosed, xrcsBeforeFirst, xrcsActive, xrcsEof, xrcsCancelled, and xrcsFaulted; Cancel is idempotent, invalidates the current row, and releases the active worksheet stream while retaining the source so an explicit sheet selection can start a new pass
The stream overload defaults to xsoBorrowed, restores the caller's initial position on close, and accepts xsoOwned to transfer ownership after a successful open; failed opens never consume caller ownership
CurrentRowView borrows the current row array without copying it and checks a generation before every access; advancing, selecting, cancelling, closing, or destroying the cursor invalidates the view and raises EXLSRowCursorViewInvalidated on later access
PeakRowBufferedBytes is a monotonic estimate since the most recent Open of the cell records, managed payloads, rich text, and format-backend data retained for one logical row; it is intended for bounded-memory regression diagnostics rather than exact heap accounting
SheetPassesStarted counts successful worksheet backend starts; inspecting sheet names or skipping a sheet through the callback facade does not open the worksheet part
Forward callback adapter
TXLSForwardReader delegates XLS, XLSX, ODS, CSV, and TSV decoding to TXLSRowCursor, converts each current-row cell into an OnCell callback, and preserves the same row bounds, column projection, formula state, rich text, password, skipped-record, stream-position, and bounded-buffer contracts
PeakRowBufferedBytes and SheetPassesStarted expose the shared cursor diagnostics on the callback surface, while classic XLS additionally retains ClassicBytesRead and ClassicPeakBufferedBytes
Reader events and record types
The reader and row cursor expose optional callbacks and plain records, all declared in lxDirectRead. Every callback follows the same shape: the record describes one streamed item, and setting Abort stops the scan (sheet events additionally accept SkipSheet)
| Cells | OnCell (type TXLSDirectCellEvent) delivers a TXLSDirectCell per cell whose Kind (TXLSDirectCellKind: xdkEmpty, xdkNumber, xdkString, xdkBoolean, xdkDate, xdkError) selects the populated value field; rich text travels as a TXLSDirectRichText holding TXLSDirectRichTextRun entries, each with a TXLSDirectRichColor (kind TXLSDirectRichColorKind), TXLSDirectRichUnderline, and TXLSDirectRichVertAlign, plus optional TXLSDirectPhoneticProperties and TXLSDirectPhoneticRun data |
| Sheet framing | OnSheet (TXLSDirectSheetEvent) can skip a whole worksheet before its cells are parsed; OnSkippedRecord (TXLSDirectSkippedEvent) reports malformed or truncated content with the record id and reason |
| Sheet layout | OnDimension, OnSheetFormat, OnColumn, OnRow, OnMerge, and OnPane deliver TXLSDirectDimension, TXLSDirectSheetFormat, TXLSDirectColumn, TXLSDirectRow, TXLSDirectMerge, and TXLSDirectPane records; pane state uses TXLSDirectPaneState (xdpsSplit, xdpsFrozen, xdpsFrozenSplit, xdpsUnknown) |
| Cursor state | TXLSRowCursor.State is a TXLSRowCursorState (xrcsClosed, xrcsBeforeFirst, xrcsActive, xrcsEof, xrcsCancelled, xrcsFaulted); the stream overload of Open takes a TXLSStreamOwnership (xsoBorrowed default, xsoOwned to transfer ownership), and CurrentRowView returns an IXLSRowCursorView borrowed view whose Valid property guards access and whose ValueByCol reads one cell of the borrowed row without copying; the view invalidates when the cursor advances |
Writer parameter and style types
The writer's typed helpers (lxDirectWrite) accept records and enums so calls stay allocation-free: WriteRichString takes a TXLSDirectRichText; AddCellStyle builds a package-level style from a TXLSDirectCellStyle whose alignment (TXLSDirectHorizontalAlignment, TXLSDirectVerticalAlignment), underline (TXLSDirectUnderline), fill pattern (TXLSDirectFillPattern), and border sides (TXLSDirectStyleBorder with TXLSDirectBorderSide) mirror the OOXML style model. Conditional formats pass a TXLSDirectConditionalFormat with TXLSDirectCfKind / TXLSDirectCfOperator / TXLSDirectCfValue / TXLSDirectCfValueKind and TXLSDirectIconSetType, data validation a TXLSDirectDataValidation, tables a TXLSDirectTable, hyperlinks a TXLSDirectHyperlink, defined names a TXLSDirectDefinedName, differential styles a TXLSDirectDxfStyle, comments a TXLSDirectComment, images a TXLSDirectImage with TXLSDirectImageFormat, charts a TXLSDirectChart with TXLSDirectChartSeries and TXLSDirectChartType, merges a TXLSDirectMergeRange, protected ranges a TXLSDirectProtectedRange, sheet protection a TXLSDirectSheetProtectionOptions set of TXLSDirectSheetProtectionOption, auto-filter sort state a TXLSDirectSortState, column options a TXLSDirectColumnOption, and page geometry a TXLSDirectPageMargins record
TXLSDirectNeedRow = procedure(Sender: TObject; RowIndex: Integer;
var Eof: Boolean) of object;
function XLSDirectColName(Col: Integer): WideString;
function XLSDirectParseRef(const Ref: WideString;
out Col, Row: Integer): Boolean;
function XLSDirectPasswordHash(const Password: WideString): WideString;
OnNeedRow pulls rows from the application: the supplier writes the row's cells straight through the writer and leaves Eof = False, or declares exhaustion with Eof = True to stop the loop. The helpers convert between coordinates and protection primitives: XLSDirectColName renders a zero-based column as its A1 letters, XLSDirectParseRef parses an A1 cell reference, and XLSDirectPasswordHash computes the legacy password hash the sheet-protection records store