HotXLS Docs

Local Pivot cache lifecycle and native layout

Version 2.384.94 adds shared-cache views, local non-OLAP Pivot Slicer creation and explicit removal, grouped-cache reconstruction, and a bounded native layout metadata generator

Shared views and Slicer creation

SecondPivot := Sheet.AddPivotTable(FirstPivot.Cache, 20, 1, 'SecondView');
Cache := Workbook.CreatePivotSlicerCache(FirstPivot, 'Category');
if Cache.ConnectPivotTable(SecondPivot) <> 1 then
  raise Exception.Create('The second view could not be connected');
Slicer := Sheet.Slicers.Add(Cache, 1, 6, 8, 8);

TXLSXWorksheet.AddPivotTable(ACache: TXLSPivotCache; DestRow, DestCol: Integer; const Name: WideString): TXLSPivotTable creates another view of a cache owned by this workbook; it validates ownership, geometry and names before attaching the view

TXLSXWorkbook.CreatePivotSlicerCache(ATable: TXLSPivotTable; const AFieldName: WideString): TXLSXSlicerCache creates or safely reuses a supported source-field cache, while TXLSXSlicerCache.ConnectPivotTable(ATable: TXLSPivotTable): Integer connects an existing local shared-cache view

TXLSXSlicers.Add(ACache: TXLSXSlicerCache; ARow1, ACol1, ARow2, ACol2: Integer): TXLSXSlicer creates the worksheet UI using explicit inclusive 1-based cell bounds; source names, cache parts, drawing references and view membership are staged before mutation

Grouped, calculated and OLAP Slicer sources, foreign caches, inconsistent imported domains and ambiguous independent same-field masks reject; supported imported view XML keeps unrelated extensions when a new UI is appended

Explicit removal and future members

if Workbook.RemoveSlicerCache(Cache, xlsxSlicerPreserveCurrentSelection) <> 1 then
  raise Exception.Create('The Slicer cache could not be removed');

TXLSXSlicerRemovalMode has xlsxSlicerClearSelection and xlsxSlicerPreserveCurrentSelection; TXLSXWorkbook.RemoveSlicerCache(ACache: TXLSXSlicerCache; AMode: TXLSXSlicerRemovalMode): Integer removes the bound UI, drawing references, native cache parts and connections together

Clear mode removes this Slicer restriction while retaining independent filters and caller predicates; preserve mode transfers its current restriction to ordinary Pivot member masks before removing the Slicer

The operation returns 1 on success and -1 for unsupported or unsafe bindings; all affected views and cache state are validated and staged before commit, and same-field ownership ambiguity rejects without guessing

TXLSPivotField.IncludeNewItemsInFilter: Boolean defaults to False; a retained manual subset excludes newly appended members unless this policy is explicitly enabled, while an unrestricted field includes them

Preserved selection therefore remains stable after source growth, while clear mode includes new source members; imported and authored member lists serialize the same future-member hiding policy

Existing collection Delete and Clear operations still guard a final bound Slicer view; use the explicit workbook operation when the cache and its connected restrictions must be removed together

Fixed grouped-cache reconstruction

Refresh stages numeric, date and explicit discrete group identities from validated base/parent links, including imported derived fields whose record columns are absent; link-only source fields retain their original values instead of being grouped themselves

Supported domains retain existing member handles, captions and group ordinals; numeric and date grouping uses one resolution per field and a fixed native group-item domain, and date grouping requires interval one

TXLSPivotCacheField.GroupAutoStart and TXLSPivotCacheField.GroupAutoEnd default to True and preserve the imported boundary policy; new values requiring domain expansion or regrouping reject before mutation

Discrete groups require an existing mapping for every source member; cyclic parents, invalid typed domains, nonunique string captions, calculated bases, member-property fields and unsupported parent resolutions reject transactionally

Ordinary Make reconstructs supported stale or missing derived record values, while MakePreview does so only on a detached copy; saving omits internal placeholder shared items from derived native domains and emits exactly the declared group-item indices

Native layout metadata preview

function TryXLSXGeneratePivotLayout(const Xml: WideString;
  Table: TXLSPivotTable; out ResultXml, Reason: WideString): Boolean;

The lxPivotXml helper stages rowItems, colItems, axis metadata and location for supported nonempty local compact views using exact field and cache-member identities; it supports ordinary hierarchies, default top or bottom subtotals and either data axis

This metadata-only operation requires explicit Cache.RefreshOnLoad=True; it preserves unknown XML and returns the original XML plus an English reason when grouped or calculated fields, custom subtotals, unsupported layout or inconsistent imported identities cannot be represented

The helper does not rewrite worksheet cells or change live table flags; callers requiring cached worksheet output must supply an appropriate writer and a separately supported materialization operation

TXLSPivotTable.MakePreview(AWriter: TlxPivotResultWriter; ALayoutWriter: TlxPivotLayoutWriter): Integer supplies synchronous layout callbacks from a detached preview, retaining the original EvaluationSourceTable identity

TlxPivotLayoutWriter receives the original table, row/column axis, copied field-index and cache-item-index vectors, TlxPivotLayoutItemKind, subtotal kind and prefix length; xlplikData, xlplikSubtotal and xlplikGrand distinguish aggregate identities without parsing captions

The vectors use TlxPivotLayoutIndices and are valid during the callback; exceptions propagate, and existing Make and single-writer MakePreview behavior remain available

TXLSPivotTables._AddOwned(ATable: TXLSPivotTable) reserves collection capacity before ownership transfer and supports internal transactional view attachment; applications should normally use worksheet authoring methods

Boundaries

Version 2.384.95 adds native cached worksheet output, read-only cross-filter availability and explicit historical-member purge; serialized native no-data display, Timeline authoring and broader grouped layout serialization retain separate acceptance boundaries