Safe Pivot worksheet materialisation
Version 2.384.90 introduces isolated Pivot evaluation and guarded worksheet result replacement; version 2.384.92 widens the supported local sources to defined names and tables resolved at each call
Ordinary ODS Pivot translation
One qualified ordinary ODS data-pilot definition comes in as an editable local-source Pivot cache and view, keeping the existing result cells and styles without rematerializing them on load; the model can be saved as XLSX with real Pivot parts or back to ODS
The ordinary aggregate profile calls for exactly two adjacent local source columns, distinct string headers, one nonempty string row field, one finite numeric SUM, COUNT, AVERAGE, MIN or MAX field and no more than 65536 source records, with DataFields[0].NumberFormat = 0
Newly authored views call for the one-header-row layout, set explicitly via FirstDataRow := FirstRow + 1, and must finish MaterializeNativePivotTable before ODS export; after source edits call RefreshPivotCache and materialise once more, and after changing an effective row, measure or grand-total caption materialise once more
Export checks the current source, cache, result values, effective captions and materialisation ownership before writing; source numbers must come through the existing ODS numeric writer unchanged, and aggregate values must match the selected source aggregate or its explicit 15-significant-digit persisted form; AVERAGE additionally demands finite agreement between the source-order running mean and source-order sum/count under that projection
COUNT checks actual source-cache freshness even when the displayed count stays put; distinct case-equivalent categories are refused because native and core grouping differ; whitespace remains category content, and no general floating-point tolerance appears
Unsupported or mixed imported collections keep the existing whole raw ODS representation, whilst unsupported typed ODS output is reported and refused ahead of destination output; raw preservation promises nothing about original ZIP or lexical XML bytes
Imported raw OOXML caches need the explicit local refresh, measure-role declaration and materialization lifecycle before becoming eligible; multiple or advanced Pivots, other measures, native expanded members, filters, layout extensions and nondefault refresh or format settings stay outside this profile
Stored captions live on, but another application's refresh may regenerate localized captions; category ordering, interactive buttons and cross-application style equivalence are not qualified
Typed admission bounds cover descriptor text, events, attributes and row allocations; the existing unsupported raw XML capture stays separate from these finite limits
Materialise a view
if Workbook.RefreshPivotCache(Pivot.CacheId) <> 1 then
raise Exception.Create('Pivot cache refresh failed');
if Workbook.MaterializePivotTable(Pivot) <> 1 then
raise Exception.Create('Pivot output cannot be replaced safely');
TXLSXWorkbook.MaterializePivotTable(ATable: TXLSPivotTable): Integer computes results from the current cache and sets them down at the view's FirstRow and FirstCol; it returns 1 on success or -1 for unsupported sources, unsafe destinations, evaluation failure or a refused workbook mutation
Refresh and worksheet recalculation stay explicit operations; successful materialisation invalidates calculation dependencies so that callers can recalculate downstream formulas where appropriate
The default overload takes blank destination cells and unchanged cells previously owned by the same view; occupied unowned cells anywhere within the complete output rectangle sink the operation, gaps the result writer does not fill included
if Workbook.MaterializePivotTable(Pivot, True) <> 1 then
raise Exception.Create('Existing Pivot values cannot be adopted safely');
TXLSXWorkbook.MaterializePivotTable(ATable: TXLSPivotTable; AAdoptExisting: Boolean): Integer may explicitly adopt existing scalar cells inside the view's declared previous rectangle on its first materialisation; it authorises no replacing of formulas, array members, rich text, metadata-bearing cells or content outside that rectangle
Ownership, resizing and movement
The view keeps exact coordinates and typed value snapshots for the written cells; XLSX saving preserves this ownership inside the Pivot definition, so later updates can validate it after reopening
Changed typed content or a removed nonblank owned cell sinks the entire update; number subtypes share a canonical numeric representation, whilst text, Boolean values and errors keep distinct identities
Shrinking or moving a result clears just the unchanged owned values no longer produced; existing cell objects, formatting and comments stay available, and unrelated cells remain outside the ownership set
Changing FirstRow or FirstCol shifts the next output whilst the previous ownership coordinates stay available for cleanup; an empty result clears the owned values and keeps an anchor-only location
Updating date criteria after reopening
Changing supported date criteria after reopening does not require adopting Pivot cells again: save writes the current materialised values and result bounds together with the updated criteria, including workbooks with Slicer and Timeline selections
Isolated preview
function TXLSPivotTable.MakePreview(AWriter: TlxPivotResultWriter): Integer; property TXLSPivotTable.EvaluationSourceTable: TXLSPivotTable;
TXLSPivotTable.MakePreview works from independent copies of the cache and view, calculated-field placeholders included, and discards them once evaluation ends; ordinary Make keeps its existing live-cache behaviour
The writer is given zero-based row and column offsets and typed values; the return value follows Make's aggregate-cell count, which is separate from the number of writer calls; a missing cache or writer yields zero, and evaluation or writer exceptions are propagated
Caller record predicates and registered owner filters stay active in previews, workbook Slicer selections included; callbacks receive the temporary evaluated view and its temporary cache
TXLSPivotTable.EvaluationSourceTable returns the live view for an ordinary evaluation and the original live view for a preview; use it when a callback must identify a connected view, reading the evaluated records from the callback's temporary Cache
Callback owners remain the caller's property; preview objects and their records must not be kept once the callback or preview call has ended
OpenDocument DATA order and result ownership
The finite row-path and column-path Data profiles choose an actual measure ordinal from the supported 1..16-measure layout and work out complete parent-prefix aggregates before an ordered result is published
Every selected occurrence keeps its source field and aggregate function, even where the same source field is referenced more than once; display captions do not identify data measures
Source edits require explicit cache refresh and OpenDocument rematerialisation, whilst sort-setting edits require rematerialisation of the current cache; whole-grid validation cannot combine individually matching cells from different result projections
The qualified column member caption profile also uses explicit RefreshPivotCache after source changes and MaterializeOdsPivotTable after a caption edit or a clearing, with source/cache identities, the old ownership ledger and the physical header values checked as a set before anything is replaced
A supported one-through-sixteen-measure column result uses its actual data width whilst retaining every represented real column axis; its complete field-header cells have separately checked sparse ownership, including headers beyond the data rectangle
Imported prior wide results keep their validated ownership for no-op saving, and explicit rematerialisation can retire only their still-owned padding; a narrower result does not capture a whole rectangular area around its extra headers
Cells immediately right of the complete headers, or below an outlying header, stay protected; the sparse header plan covers only the exact represented field-header positions
Unknown, malformed, stale or changed header ownership cannot authorise replacement, and matching text alone does not grant permission to adopt an occupied cell
The finite qualification on LibreOffice 26.2.5.2 takes six row and column data layouts through open, explicit refresh, save and reopen, then a typed library return with the original input streams and workbook owners released
The selected cases cover eight-level row and column paths, uneven source-weighted averages, hidden row prefixes and a collapsed column prefix; the supported selected-measure extensions also keep complete column headers and source-bound native grand captions through explicit refresh and typed reopening
These finite observations do not cover every hierarchy, data set, locale, application version, provider or interactive combination
Safety boundaries
Materialisation needs a view and cache registered in the same workbook plus a supported local rectangular, defined-name or table source; source resolution follows current names and table extents, and unsupported or unresolved sources are refused before mutation
Current source geometry, other Pivot locations, structured tables, query result ranges, merged cells and fixed or dynamic arrays must not intersect the new output or the old owned cells awaiting clearing; table totals stay protected even though they are excluded from cache records
Validation and output staging run under a read lease, then come the normal workbook mutation guard and generation check; a frozen read-only workbook view sinks materialisation without replacing cells or changing geometry
Filters must be read-only and follow the workbook's ordinary single-writer contract; isolation stops normal preview calculations from altering the live cache, yet arbitrary callback writes through separately captured live objects cannot be rolled back
This operation materialises the library's calculated result layout; full native Pivot layout authoring, Slicer UI creation and cross-filter no-data display evaluation remain separate capabilities
OpenDocument row-path headers and copied views
The represented two-through-eight-row-field profile keeps one header row for a single numeric measure and two header rows where several independent measure occurrences exist
In the two-header layout, the first row carries the view's explicit DataCaption at the first measure column, while the second holds row-field and measure captions; a successful MaterializeOdsPivotTable publishes that full geometry and the corresponding FirstDataRow together
Header and result together have to follow one supported whole-grid projection; a one-row shift, a caption that is missing or a result changed in isolation is refused instead of being accepted as a similar layout
Within this local row-path profile, a metadata-only Pivot clone receives independent cache/view state without claiming the source's old result cells as destination ownership; provide its represented local source and explicitly materialise it before saving
A represented whole-worksheet graph copy carries cells, typed source/cache relationships, result ownership and exact sparse column-header ownership along with the view coordinates and captions, keeping the row-path two-header data-start relationship where it applies
A metadata-only clone retains independent cache and view state without claiming destination result or header cells; it requires its represented local source and explicit safe materialisation before saving a result
Copying does not give stale ownership, unrelated occupied cells or foreign contexts permission to overwrite
These operations retain the usual source resolution, explicit refresh, collision, budget and workbook mutation checks; implicit refresh and general native-layout conversion are not added
Supported homogeneous parent subtotals preserve an explicit source-owned caption through native refresh, whilst each measure and imported row subtotal retains its concrete aggregation
Literal question marks and backslashes in single-measure SUM captions survive the caption-template encoding; arbitrary templates, mixed-function parent subtotals and changed result ownership are still not admitted