HotXLS Docs

ScanIndexedColorUsage method

Returns a deterministic inventory of all 56 physical workbook palette slots and the indexed-color definitions and references that use them

The method is available on both IXLSWorkbook and TXLSXWorkbook and does not modify palette, cells, styles, conditional formats, or workbook state

Syntax

function ScanIndexedColorUsage: TXLSIndexedColorUsageArray;

Result

The returned array always contains 56 entries in ascending physical-slot order from 8 through 63

FieldMeaning
ColorIndexThe corresponding public palette index from 1 through 56
PaletteSlotThe physical BIFF or OOXML indexed-color slot from 8 through 63
ARGBThe normalized opaque color currently stored at the slot, or zero if it cannot be resolved
DefinitionCountThe number of indexed definitions that point to the slot
ReferenceCountThe number of objects, cells, or covered conditional-format positions that reference those definitions
KindsA set describing every observed consumer category
LockedTrue when the slot has at least one definition or reference and therefore must be preserved by a palette optimization plan

Consumer coverage

Kinds can include fonts, fill foregrounds, fill backgrounds, gradients, borders, conditional formats, charts, shapes, comments, worksheet settings, and other indexed consumers

Classic XLS scanning includes fonts, XF fills and borders, worksheet gridlines, shape and comment colors, rich-text and chart font references, legacy conditional formats, and BIFF12 data bars or color scales

XLSX scanning includes materialized cell style references, style overlays, named styles, font, fill, gradient and border pools, differential styles, data bars, and color scales

Direct RGB, theme, automatic, system, and invalid color tokens do not lock physical palette slots

Performance and state contract

The scan traverses stored sparse cells and existing style metadata only; it does not materialize packed cells or iterate unused worksheet coordinates

Counts use saturating 64-bit arithmetic so large ranges cannot wrap to a smaller value

Repeated calls over an unchanged workbook return identical entries and leave custom palette counts and storage statistics unchanged

Example

Usage := Workbook.ScanIndexedColorUsage;
for I := 0 to High(Usage) do
  if Usage[I].Locked then
    PreservePaletteSlot(Usage[I].PaletteSlot);

See also