HotXLS Docs

Non-OLAP Pivot Slicer selection

Version 2.384.88 brings typed member selection to imported non-OLAP Pivot Slicer caches that can be bound to ordinary local cache fields and their connected PivotTable views

Inspect and change a selection

SlicerCache := Workbook.SlicerCaches.FindByName('SlicerCategory');
if (SlicerCache = nil) or not SlicerCache.IsNonOlapPivot then
  raise Exception.Create('A non-OLAP Pivot Slicer cache is required');
if SlicerCache.SetSelectedItems([1]) <> 1 then
  raise Exception.Create('Slicer selection could not be changed');

TXLSXSlicerCache.IsNonOlapPivot picks out the tabular Pivot shape; TXLSXSlicerCache.ItemCount, TXLSXSlicerCache.ItemCacheIndex and TXLSXSlicerCache.ItemSelected expose the parsed member list and selection

Member-list positions are zero-based; each ItemCacheIndex identifies a shared member in the bound Pivot cache field, so number, text, Boolean, date, blank and error members hold separate identities even where their displayed text matches

TXLSXSlicerCacheItem stores a CacheItemIndex: Integer plus Selected: Boolean; TXLSXSlicerCacheItems is its dynamic-array type, whilst the cache exposes selection through read-only indexed properties

TXLSXSlicerCache.SetSelectedItems takes shared-member indices and returns 1 on success or -1 for unsupported, invalid or unsafe bindings; an empty selection is refused because the file format insists on at least one selected member

TXLSXSlicerCache.ClearSelection follows the same status convention and selects every member; it lifts this Slicer constraint whilst leaving independent restrictions on other fields alone

Shared views and existing filters

Selected members within one Slicer cache form a union; applicable Slicer caches intersect for each explicitly connected view, even where the selected field is missing from that view's displayed axes; several UI Slicer views of one cache share the same selection

Call TXLSPivotTable.Make with the application's result writer to work out current results; cache selection changes rewrite no worksheet cells and regenerate no imported native layout

Excel keeps non-OLAP Slicer selections as ordinary Pivot member hiding and page selection; the format records nothing about which operation created an individual hidden flag

Before an imported binding is modified, HotXLS validates that its old same-field hidden and page masks match the effective old Slicer selection; matching masks count as Slicer-managed, whilst inconsistent or ambiguous masks are refused without guessing; unrelated-field manual, page and advanced filters stay active

Saving and source refresh

Saving updates the Slicer selection and connected Pivot member masks together, keeps imported XML namespaces and unknown extensions, and remaps sheet connections to their saved identities; extended Slicer cache identifiers stay distinct from ordinary workbook Pivot cache identifiers

Local Pivot cache refresh holds on to selected shared-member indices; explicit subsets shut out new members, whilst cleared selections admit the complete refreshed domain

Boundaries and failure behaviour

Selection changes validate every connected view and member before commit and use the workbook's mutation guard; failure leaves the existing selection, view restrictions and original XML intact

Adding, deleting and clearing Slicer caches likewise go through the workbook's write guard; a frozen workbook view cannot alter connected Pivot results through collection mutation

Deleting a bound non-OLAP Pivot cache, or clearing a collection holding one, is refused before mutation; the explicit RemoveSlicerCache lifecycle operation removes its native views and either clears its selection or transfers it to ordinary Pivot masks

OLAP and table-cache selection, grouped or calculated source fields, missing connections, inconsistent domains and ambiguous imported same-field masks stay outside this operation; unsupported cache contents keep their original representation

This selection API handles imported and supported authored Pivot Slicer caches; shared-view authoring and explicit cache removal arrive in 2.384.94; safe worksheet materialisation can replace supported calculated output, whilst cross-filter no-data display evaluation remains separate work

Deleting the last UI view of a bound non-OLAP cache is refused before its drawing, view or cache changes; deleting one of several UI views leaves their shared cache and selection in place

Clearing a worksheet's Slicer views checks every affected cache before any view is removed; a final bound view triggers atomic rejection, whilst views shared with other worksheets keep their cache and selection

Additional record filters

TlxPivotRecordFilter = function(ATable: TXLSPivotTable;
  ARecordIndex: Integer): Boolean of object;
procedure TXLSPivotTable.SetRecordFilter(AOwner: TObject;
  AFilter: TlxPivotRecordFilter);
procedure TXLSPivotTable.ClearRecordFilter(AOwner: TObject);
property TXLSPivotTable.ExternalRecordFilter: TlxPivotRecordFilter;

TXLSPivotTable.SetRecordFilter registers, or replaces, one callback per non-nil owner, and TXLSPivotTable.ClearRecordFilter takes away that owner's callback; passing a nil callback to SetRecordFilter removes it too

Registered callbacks and the optional TXLSPivotTable.ExternalRecordFilter intersect ahead of the table's own filters and aggregation; the workbook registers its Slicer callback independently, so it never overwrites the caller's predicate

Callbacks receive zero-based record indices, are snapshotted for every Make call and are neither serialised nor copied by AssignPivotOnly; owners and callback targets stay caller-owned and must outlive their registration