HotXLS Docs

Cell Formatting Basics

Overview

Formatting in HotXLS is applied through a unified cell properties model, enabling precise control over number representations, text orientation, alignment, borders, and colors in both XLS (BIFF8) and XLSX workbook instances

Empty and literal-only number-format sections

Version 2.384.524 keeps an explicitly empty positive, negative or zero section empty when producing formatted display text, so a numeric value with ;;; displays no characters

An omitted section retains the existing fallback rule, while an empty overall format retains General display; for example, 0; shows positive numbers and zero but hides negative numbers

A selected literal-only section emits its literal text without appending the numeric value, and an explicit fourth text section controls strings even when that section is empty or contains no @ placeholder

Section separators inside quoted text or escaped characters remain literal text; "a;b"0 therefore formats 12 as a;b12

Conditions select their actual section before date recognition, and quoted date tokens remain literals; Boolean and error display keep their existing behavior

These rules apply to the shared display formatter and the XLSX cell's FormattedText property; they do not change stored values, replace the complete custom-format engine or qualify general automatic row layout

Font Formatting

Access the IXLSFont interface through a range or cell reference to modify text styling; the following properties control character presentation

Borders and Fills

Configure borders and background patterns using the interior and border interfaces

Font-family classification retention

The XLSX font-family classification is separate from the font name; an unspecified classification remains unset through buffered and streaming output and file or stream save/reopen

TXLSXFont.Family = 0 omits the family element instead of substituting Swiss; explicit values 1 through 5 retain Roman, Swiss, Modern, Script and Decorative classifications respectively

Other positive values retain the existing pass-through behavior; negative values raise EArgumentException during XLSX saving

A rejected save does not guarantee restoration of an output stream or removal of a partially written file

Encoded styles, packed cells and resolved formats

Saving preserves fonts, fills, borders, number formats, alignment and protection referenced only by encoded cell formats, packed values, worksheet defaults, overlays or named styles

Style-pool compaction removes unused entries while remapping retained references and preserving composite parents, linked components and represented built-in formats

Formatting a range updates only selected components of matching packed records without creating Cell objects; untouched numeric, string, Boolean, error, blank, empty and null records retain their stored values and style indexes

A range that contains no packed records leaves the packed storage unchanged; a projected style index outside the Word range is rejected before the packed storage, composite count or overlay list changes

Saving retains its existing packed-materialization boundary; this change does not add general rollback for every allocation failure in save or ordinary object formatting

Resolved format queries

TXLSXWorksheet.GetCellVisibleFormat(Row, Col, BuiltinNumFmtId) returns decoded component indexes and a separate built-in number-format ID

The TXLSXStyleOverlays.Resolve, ResolveRowDefault, ResolveColumnDefault and HasVirtualStyle families provide the same additional output

var
  Style: TXLSXCellStyleState;
  BuiltinNumFmtId: Integer;
begin
  Style := Sheet.GetCellVisibleFormat(1, 1, BuiltinNumFmtId);
end;

The public style-state record keeps its eight Integer fields; use the additional output when a built-in format is combined with other components

The existing overloads return an exact representable state using direct references, the standard date index or an existing matching composite; otherwise they raise an error directing the caller to the resolved overload

Resolving does not register a composite merely to encode a read result; the visible-format getter retains its existing table-style preparation behavior

Conversion and remaining boundaries

The standard short-date semantic code is M/D/YY; supported XLS and ODS conversion paths retain the separate built-in format instead of falling back to General

The semantic renderer retains its existing refusal of directly encoded built-in formats beyond its supported date format; the numeric built-in 4 conversion checks do not broaden that rendering contract

Internal blank, empty and null identities are preserved by packed formatting; their distinct identities are not all represented separately by an XLSX reopen

Populate style pools before retaining absolute FormatIndex values; arbitrary later direct pool growth is outside this save-compaction guarantee

Complete workbook default appearance at coordinates without a stored Cell, general foreign-workbook appearance publication and native visual equivalence remain separate work

Stored cells and the default style

An existing XLSX cell that omits its s attribute uses the same complete style as an explicit s="0" cell, including represented font, fill, border, number format, alignment and protection

Row and column defaults do not replace the format selected by an existing cell; the same rule applies when saving assigns that cell a different style index

Numeric, string, rich-text, formula, date and declared empty cells retain their represented styles through file and stream saves and subsequent reopening

An otherwise empty cell with a named-style parent remains in the output so its explicit default-style override is preserved

Ordinary unstyled empty nodes do not create extra cells; formatting at coordinates without a stored cell remains subject to the existing worksheet-default limitations

Automatic gradient colors

An automatic gradient stop retains an explicit <color auto="1"/> child in XLSX and Strict output, as required by the spreadsheet format

Explicit RGB, theme and indexed stops keep their represented values and tint; automatic color selection remains dependent on the consuming application

Source theme version

XLSX and supported Strict saves retain valid represented defaultThemeVersion metadata, including when the model carries that metadata independently of unknown XML attributes

An absent value remains absent; a valid represented value takes precedence over a conflicting raw attribute and is written only once, while invalid or ambiguous source metadata retains the existing raw preservation behavior

This preserves source metadata and does not introduce a public theme-version setter or extend XLSB theme-version persistence

Saving ordered row and column formatting

XLSX saves retain the represented order of overlapping full-row and full-column formatting, including partial formatting and explicit zero resets

Because worksheet row defaults take precedence over column defaults in the saved format, differing intersections receive explicit cell formatting where needed; existing cell values and their represented local styles remain in their established output path

Each worksheet build allows at most 1048576 potentially emitted compensating coordinates whose complete style differs from the serialized row default; equivalent or fully covered intersections do not consume that capacity

The count deducts existing cells only when their own XML output is guaranteed without a cell-write callback or an alternate value/order owner; callbacks that may skip cells and other uncertain owners retain conservative accounting

A larger required region raises EInvalidOperation before row XML is generated; this adds no transactional-output guarantee, and existing save preparation or partial file/stream output may already have occurred

The finite save/reopen qualification covers represented model and package styles, without a new native rendering or pixel-equivalence guarantee

The fictitious February 29, 1900

In the 1900 date system, a date-formatted numeric worksheet serial from 60 up to but excluding 61 remains numeric when loaded, including fractional values such as 60.5

This worksheet day has no lossless TDateTime or varDate representation; retaining the original numeric serial prevents a later save from changing 60 to 59 or 60.5 to 59.5

The represented date format remains attached to the cell through file and stream save/reopen; ordinary numbers, text, representable date-typed values and the 1904 date system retain their existing behavior

This reader rule concerns worksheet storage and does not change chart date-axis transforms or establish a general validity guarantee for arbitrary date ranges

Date values and elapsed-time display

For XLSX cells, FormattedText and GetFormattedTextColor interpret a date-typed value using the owning workbook's date system when the selected number-format section contains an elapsed-time token such as [h], [m] or [s]

Calendar-date sections continue to use the date's calendar value, while an elapsed-time section uses the corresponding worksheet serial; under the 1904 date system, a date with worksheet serial 1.5 therefore displays as 36:00:00 with [h]:mm:ss

The 1900-system adjustment includes the fractional part of the last day before March 1, 1900: OA date 60.5 represents February 28 at noon and maps to worksheet serial 59.5, giving 1428:00:00 with [h]:mm:ss; OA date 61 is outside that adjustment window

Quoted or escaped bracket text remains literal text, including elapsed markers and color names; a real color prefix such as [Red] affects the reported text color without appearing in the elapsed-time text, while a quoted or escaped color name does not set a format color

Advanced callers using TXLSFormater directly can provide the calendar value and its corresponding worksheet serial separately

function TXLSFormater.GetDisplayDateValue(Value: Variant;
  NumberFormat: WideString; ElapsedSerial: Double): WideString;

This method is declared in lxStandard; pass the original date-typed Value and an ElapsedSerial already expressed in the intended workbook's date system, since the formatter has no owning workbook from which to infer it

The additional serial is used only when the existing formatting path selects an elapsed-time section; section selection, conditions and mixed calendar/elapsed formats retain the formatter's existing rules

See Recognized built-in formats on import and save for retained imported format codes