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 colours in both XLS (BIFF8) and XLSX workbook instances

Empty and literal-only number-format sections

When formatted display text is produced, version 2.384.524 leaves an explicitly empty positive, negative or zero section empty, so a numeric value with ;;; displays no characters

A section that is omitted keeps the existing fallback rule, and an empty overall format still shows General; for example, 0; shows positive numbers and zero but hides negative numbers

When a literal-only section is selected, its literal text is emitted without the numeric value appended, and an explicit fourth text section governs strings even where that section is empty or has no @ placeholder

Separators inside quoted text or escaped characters stay 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 behaviour

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

Font Formatting

Reach the IXLSFont interface through a range or cell reference to change text styling; the properties listed below govern how characters are presented

Borders and Fills

Set borders and background patterns through the interior and border interfaces

Font-family classification retention

The XLSX font-family classification is distinct from the font name; where no classification is specified it stays unset through buffered and streaming output and through a file or stream save and reopen

TXLSXFont.Family = 0 leaves out the family element rather than substituting Swiss; explicit values from 1 to 5 keep the Roman, Swiss, Modern, Script and Decorative classifications in that order

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

A save that is rejected does not guarantee that an output stream is restored or that a partially written file is removed

Encoded styles, packed cells and resolved formats

A save preserves fonts, fills, borders, number formats, alignment and protection that are referenced only through encoded cell formats, packed values, worksheet defaults, overlays or named styles

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

Formatting a range changes only the chosen components of matching packed records, with no Cell objects created; numeric, string, Boolean, error, blank, empty and null records left untouched keep their stored values and style indexes

A range holding no packed records leaves packed storage as it was; a projected style index outside the Word range is rejected before packed storage, the composite count or the overlay list changes

Saving retains its existing packed-materialisation 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 retains its eight Integer fields; use the extra output where a built-in format is combined with other components

The existing overloads return an exactly representable state through direct references, the standard date index or an existing matching composite; if none applies, they raise an error that points 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 behaviour

Conversion and remaining boundaries

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

The semantic renderer still refuses directly encoded built-in formats beyond the date format it supports; the conversion checks for numeric built-in 4 do not widen that rendering contract

Packed formatting preserves the internal blank, empty and null identities; an XLSX reopen does not represent all of those distinct identities separately

Fill the style pools before absolute FormatIndex values are retained; later direct pool growth of an arbitrary kind falls outside this save-compaction guarantee

Full workbook default appearance at coordinates with no stored Cell, publication of general foreign-workbook appearance, and native visual equivalence stay 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, covering the represented font, fill, border, number format, alignment and protection

Defaults for rows and columns do not replace the format an existing cell selects; the same rule holds when a save gives that cell a different style index

Numeric, string, rich-text, formula, date and declared empty cells keep their represented styles through file and stream saves and the reopening that follows

A cell that is otherwise empty but has a named-style parent stays in the output, preserving its explicit default-style override

Ordinary empty nodes with no styling add no extra cells; formatting at coordinates with no stored cell is still bound by the existing worksheet-default limitations

Automatic gradient colours

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 colour selection remains dependent on the consuming application

Source theme version

XLSX and supported Strict saves retain valid represented defaultThemeVersion metadata, even where the model holds that metadata separately from unknown XML attributes

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

This keeps source metadata intact, without adding a public theme-version setter or extending XLSB theme-version persistence

Saving ordered row and column formatting

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

In the saved format, worksheet row defaults outrank column defaults, so intersections that differ get explicit cell formatting where necessary; existing cell values and their represented local styles stay on their established output path

Each worksheet build allows at most 1048576 compensating coordinates that may be emitted where the complete style differs from the serialized row default; intersections that are equivalent or fully covered use none of that capacity

Existing cells are deducted from the count only where their own XML output is certain, with no cell-write callback and no alternate value or order owner; callbacks that might skip cells, and other uncertain owners, keep the accounting conservative

A larger required region raises EInvalidOperation before row XML is generated; that offers no transactional-output guarantee, and save preparation or partial file or stream output may already have happened

The finite save and reopen qualification covers represented model and package styles, with no new guarantee of native rendering or pixel equivalence

The fictitious 29 February 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; keeping the original numeric serial stops 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 behaviour

This reader rule is about worksheet storage; it neither changes chart date-axis transforms nor gives a general validity guarantee for arbitrary date ranges

Date values and elapsed-time display

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

Calendar-date sections continue to use the date's calendar value, whilst 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 1 March 1900: OA date 60.5 represents 28 February 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 colour names; a real colour prefix such as [Red] affects the reported text colour without appearing in the elapsed-time text, whilst a quoted or escaped colour name does not set a format colour

Advanced callers using TXLSFormater directly can supply the calendar value and its matching worksheet serial as separate arguments

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 date system of the intended workbook, as the formatter has no owning workbook from which to infer one

The extra serial comes into play only when the existing formatting path selects an elapsed-time section; section selection, conditions and formats mixing calendar and elapsed time keep the formatter's existing rules

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