HotXLS Docs

Local Pivot cache lifecycle and native layout

Version 2.384.94 brings 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 a further view of a cache owned by this workbook; ownership, geometry and names are validated before the view is attached

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

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

Grouped, calculated and OLAP Slicer sources, foreign caches, inconsistent imported domains and ambiguous independent same-field masks are refused; 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 offers xlsxSlicerClearSelection and xlsxSlicerPreserveCurrentSelection; TXLSXWorkbook.RemoveSlicerCache(ACache: TXLSXSlicerCache; AMode: TXLSXSlicerRemovalMode): Integer takes away the bound UI, drawing references, native cache parts and connections in one go

Clear mode lifts this Slicer restriction whilst keeping independent filters and caller predicates; preserve mode hands its current restriction over to ordinary Pivot member masks before the Slicer goes

The operation returns 1 on success and -1 for unsupported or unsafe bindings; every affected view and the cache state are validated and staged before commit, and same-field ownership ambiguity is refused rather than guessed at

TXLSPivotField.IncludeNewItemsInFilter: Boolean defaults to False; a retained manual subset shuts out newly appended members unless this policy is explicitly enabled, whilst an unrestricted field takes them in

Preserved selection therefore stays stable after source growth, whilst clear mode takes in new source members; imported and authored member lists serialise the same future-member hiding policy

The existing collection Delete and Clear operations still guard a final bound Slicer view; reach for the explicit workbook operation when the cache and its connected restrictions must go together

Fixed grouped-cache reconstruction

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

Supported domains hold on to existing member handles, captions and group ordinals; numeric and date grouping uses a single resolution per field and a fixed native group-item domain, and date grouping insists on interval one

TXLSPivotCacheField.GroupAutoStart and TXLSPivotCacheField.GroupAutoEnd default to True and keep the imported boundary policy; new values calling for domain expansion or regrouping are refused before mutation

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

Ordinary Make rebuilds supported stale or missing derived record values, whilst MakePreview does so only on a detached copy; saving leaves internal placeholder shared items out of derived native domains and emits precisely 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, drawing on exact field and cache-member identities; it copes with ordinary hierarchies, default top or bottom subtotals and either data axis

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

The helper rewrites no worksheet cells and changes no live table flags; callers needing cached worksheet output must supply an appropriate writer and a separately supported materialisation operation

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

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

The vectors use TlxPivotLayoutIndices and stay valid during the callback; exceptions propagate, and the existing Make and single-writer MakePreview behaviour remains available

TXLSPivotTables._AddOwned(ATable: TXLSPivotTable) reserves collection capacity ahead of the ownership transfer and backs internal transactional view attachment; applications would normally use the worksheet authoring methods

Boundaries

Version 2.384.95 adds native cached worksheet output, read-only cross-filter availability and explicit purging of historical members; serialised native no-data display, Timeline authoring and broader grouped layout serialisation keep their separate acceptance boundaries