HotXLS Docs

Cells and Ranges

A common task when using HotXLS is to specify a cell or range of cells and then do something with it, such as enter a value or change the format
A Range object in HotXLS can be either a single cell or a range of cells. The following topics show the most common ways to identify and work with Range objects
 
»Cell and Range A1 notation
»Cell Index numbers
»Range Index numbers
»Referring to Rows
»Referring to Columns
»Range Offset

Packed XLSX cell lifecycle

Random reads and loaded-cell iteration traverse mixed styled runs in packed XLSX storage without skipping stored cells, inventing extra cells or carrying a style from an unmatched run into another cell

Read-only snapshots, loaded-cell cursors and content capture return packed error values as typed varError values; materialization and supported save or copy paths use the same error conversion

Standard error tokens survive XLSX file and stream saving; the existing reader represents #NAME? with its internal error alias, while unrecognized error codes use the established #VALUE! fallback

Both internal #NAME? codes are members of the error set, so a value forced to the alias is never flattened: ERROR.TYPE answers 5 for either, and a saved and reopened workbook carries the canonical code because the file stores the token rather than the number - the same error, reported under the canonical identity

Public bulk writers retain their existing accepted value types; this repair does not add a bulk error-writing API

Retention of nonzero packed style indices during materialization and subsequent style-pool compaction remains a separate limitation

Cell collection construction

Allocating an OOXML worksheet cell collection can raise EOutOfMemory; cleanup safely releases a partially initialized collection and preserves that exception even if its first internal allocation fails

Once memory becomes available, the collection can be constructed again and used normally

Bounded Classic stored chart-cell inspection

TXLSWorksheet.ReadCachedChartCell(Row, Col, MaxBytes, MaxTextCharacters) reads zero-based Classic XLS coordinates without creating cells, calculating formulas, cloning compiled formulas, warming the shared-string cache or changing the workbook generation

The returned TXLSCachedChartCell has Kind: TXLSCachedChartCellKind, Number: Double, Text: WideString, ReadBytes: Int64, TextCharacters: Int64, Generation: UInt64 and CacheState: TXLSFormulaCacheState; ccckAbsent represents missing or empty content and merged non-anchor cells, ccckNumber represents a finite numeric result, and ccckText contains a detached counted UTF-16 string

Formula cells require a stored xlfcsLoaded or xlfcsCalculated cache; missing or invalidated caches raise EInvalidOperation instead of evaluating their formulas, while stored empty or null caches return ccckAbsent

Shared-string length and cached varUString or varOleStr length are checked before copying, preserving embedded NUL characters and surrogate code units; arrays, by-reference variants, errors, Boolean values, ANSI varString caches and unknown cache types are explicitly unsupported

A text result of n UTF-16 code units charges ReadBytes = 4*n and TextCharacters = 2*n for the counted source and detached output; a number charges eight bytes and no text characters, and absence charges neither

The method rejects negative limits with EArgumentOutOfRangeException, coordinates outside rows 0 through 65535 or columns 0 through 255 with ERangeError, and exceeded limits or non-finite values with EInvalidOperation; callers must additionally budget any numeric formatting or copied category text produced from the returned value

Stored calendar dates and typed varDate formula caches follow the current workbook Date1904 setting, while ordinary numeric doubles retain their exact stored value; a stored calendar date in the phantom 1900 interval [60, 61) is rejected rather than treated as a real date

TXLSWorksheet.IsCachedChartCellVisible(Row, Col) uses the same zero-based coordinate bounds and reads stored row and column hidden flags without materialization; a chart capture that requires visible-only plotting must check this result and apply its documented hidden-data policy

Both methods acquire a nested workbook read lease; a multi-cell chart source must retain an outer lease, verify the returned Generation, resolve formula references against the exact borrowed workbook and local worksheet without external or spanning references, and validate reference bounds and formula provenance before using these values

XLSX in-cell images and checkboxes

TXLSXCell.SetInCellImage(Data, ContentType, AltText, Decorative) stores a local PNG or JPEG as cell content, with copied encoded bytes and a rich-value metadata graph in the XLSX package

The setter validates PNG chunk bounds, checksums and its end marker, or JPEG frame and container markers before changing the cell; raster decoding remains the responsibility of the renderer

ContentType is image/png or image/jpeg, Decorative defaults to False, and AltText is preserved as image metadata

SetInCellImage replaces the formula, cached content and rich text, rejects array-formula cells, and uses #VALUE! as the ordinary fallback cell value; the library does not calculate the IMAGE function or download remote images

InCellImage returns a detached TXLSInCellImageSnapshot with Availability: TXLSCellFeatureAvailability, Data, ContentType, AltText, Decorative and CalcOrigin; xlcfaAbsent means no image metadata, xlcfaSupported means a resolved local PNG or JPEG, and xlcfaUnsupported means the existing metadata cannot be interpreted safely

ClearInCellImage removes the image and clears its fallback value; assigning another value or formula removes the image as part of replacing cell content

TXLSXCell.SetCheckbox(DefaultState: TXLSCheckboxDefaultState) creates a cell-control format and initializes the value, with xlcdUnchecked, xlcdChecked or xlcdBlank; the default is xlcdUnchecked

CellControl returns TXLSCellControlSnapshot with Kind: TXLSCellControlKind, DefaultState and the underlying Value; kinds are xlcctNone, xlcctUnknown and xlcctCheckbox

The Checkbox format belongs to formatting, so value or formula assignments retain it and Range.Clear clears content while retaining the format; ClearCellControl removes that format while preserving the value, and Range.ClearAll removes both

TXLSXWorksheet.ReadInCellImage(Row, Col, MaxBytes) and TXLSXWorksheet.ReadCellControl(Row, Col) read one-based coordinates under a read lease without creating missing cells or recalculating formulas; MaxBytes defaults to High(Int64) and rejects an oversized image before copying its bytes

Explicit cell-level styles, local image metadata, default Checkbox state and Boolean values survive XLSX save and reload, range copies and moves, structural row or column edits, and same-workbook content snapshot restoration; supported cross-workbook copies rebuild destination references

Unknown control bags, rich-value types and malformed references stay explicitly unsupported; ordinary Open XML saves retain their source metadata when PreserveUnsupportedParts is enabled, while copying unknown cell-feature metadata to another workbook is rejected before changing the destination

Adding a supported feature to an imported property bag or image graph with an unsupported namespace or conflicting owner relationships is rejected on save instead of rebuilding that graph from guessed metadata

Sparse inherited Checkbox formats

TXLSXWorksheet.SetRowCheckboxFormat(FirstRow, LastRow, DefaultState) and SetColumnCheckboxFormat(FirstCol, LastCol, DefaultState) apply an inclusive one-based axis span without creating cells or initializing values; DefaultState defaults to xlcdUnchecked

ClearRowCellControlFormat(FirstRow, LastRow) and ClearColumnCellControlFormat(FirstCol, LastCol) explicitly clear the corresponding inherited format while preserving values; invalid spans raise EArgumentOutOfRangeException before mutation

Direct cell controls and direct clears take precedence over inherited formats, finite copied format regions take precedence over rows, and rows take precedence over columns regardless of assignment order; the latest assignment at the same level wins

An imported cell element has a direct default XF when its s attribute is omitted, preserving the empty clear masks that Excel writes without an explicit zero index; missing cell elements still inherit the axis format

An absent cell retains Value = Unassigned even when its inherited Checkbox default is checked; the default is insertion metadata and does not manufacture a Boolean value during reading or rendering

FormatIndex assignment replaces the direct control format, including an explicit zero assignment that masks inherited controls; partial font, fill, border, number, alignment or protection changes retain the control format

Inherited formats survive structural edits, supported range and sheet copies and XLSX roundtrips; a cross-workbook copy remaps known property bags and rejects unknown inherited control metadata before changing the destination

Save and semantic normalization check sparse boundary complexity before traversing it, with limits of 1,000,000 partitions and 16,000,000 estimated overlay-resolution checks; an excessively fragmented control graph raises EXLSXSemanticBudget instead of starting an unbounded Cartesian walk

TXLSXRange.ApplyFormatPatch accepts xfpCellControl to copy the effective Checkbox format or clear without changing values, replacing existing direct control formats and rejecting unknown controls before destination mutation

TXLSXCellStyleState.CellControlSlot is the overlay representation: zero is an explicit clear, 1 through 3 identify unchecked, checked and blank Checkbox defaults, and negative slots reference imported feature XFs; imported slot numbers belong to their workbook and must be remapped during cross-workbook copying

Read-only control snapshots and semantic comparison use the effective sparse format without materializing missing cells; content snapshots preserve direct control masks, and CellImageCount counts stored supported or unsupported in-cell image carriers without copying image bytes

Portable capture draws Boolean Checkbox values and explicitly rejects blank or non-Boolean Checkbox appearance; the requested grid quota is checked before walking a large inherited span

These APIs are available on TXLSXWorkbook cells; the Classic XLS engine does not expose modern cell-control or rich-value image creation

GetConversionReport reports in-cell image and cell-control losses for OpenDocument and XLSB output, which retain fallback values while omitting the modern feature metadata; use checked saving to review or reject those losses

The package graph follows Microsoft's local image rich-value specification and Checkbox feature property bag specification; availability in a particular Excel build does not establish support in this library, and library roundtrips do not establish native rendering equivalence in an Excel build without these features

The compatibility probe on Excel 16.0 build 20430 opened and saved the generated Checkbox package, but exposed no usable Checkbox or local in-cell image authoring API; it opened the image package with the required rich-value metadata flags and replaced its unsupported local image with #FIELD! on re-save