HotXLS Docs

TXLSDxfStyle class

Unit: lxCondFormat

Differential XF (DXF) style override carried by a CF12 conditional-formatting rule, per [MS-XLS] §2.4.86. When a CF12 rule fires, Excel uses the DXF to change the cell's font colour, fill, font weight, italic, underline, or number format without altering the cell's base XF. Accessed via TCondFormatRule.Style (lazy-created on first read; the returned object is owned by the rule). Available since v2.35.0; v2.39.0 adds theme-colour encoding to the three colour slots.

Two colour modes per slot

Each colour slot (font colour, fill background, fill foreground) supports two mutually exclusive modes:

Whichever Set was called last wins for that slot. HasXxxColor returns True in either mode; existing callers that only check HasXxxColor and read XxxColor continue to work, treating theme-mode slots as having colour 0 (a downgrade rather than a crash). Use the paired XxxColorIsTheme / XxxColorThemeId / XxxColorThemeTint read-only properties to inspect the active mode.

Declaration

type
  TXLSDxfStyle = class
    constructor Create;
    function IsEmpty: Boolean;

    // Font color slot
    procedure SetFontColor(Color: LongWord);
    procedure SetFontColorTheme(ThemeId: Word; Tint: Single);
    property HasFontColor: Boolean;
    property FontColor: LongWord;
    property FontColorIsTheme: Boolean;
    property FontColorThemeId: Word;
    property FontColorThemeTint: Single;

    // Fill background color slot
    procedure SetFillBgColor(Color: LongWord);
    procedure SetFillBgColorTheme(ThemeId: Word; Tint: Single);
    property HasFillBgColor: Boolean;
    property FillBgColor: LongWord;
    property FillBgColorIsTheme: Boolean;
    property FillBgColorThemeId: Word;
    property FillBgColorThemeTint: Single;

    // Fill foreground color slot
    procedure SetFillFgColor(Color: LongWord);
    procedure SetFillFgColorTheme(ThemeId: Word; Tint: Single);
    property HasFillFgColor: Boolean;
    property FillFgColor: LongWord;
    property FillFgColorIsTheme: Boolean;
    property FillFgColorThemeId: Word;
    property FillFgColorThemeTint: Single;

    // Fill pattern
    procedure SetFillPattern(Pattern: Byte); // FLS_* (1 = solid)
    property HasFillPattern: Boolean;
    property FillPattern: Byte;

    // Font weight
    procedure SetFontBold(Bold: Boolean);
    property HasFontBold: Boolean;
    property FontBold: Boolean;

    procedure SetFontItalic(Italic: Boolean);
    property HasFontItalic: Boolean;
    property FontItalic: Boolean;

    // Underline style: 0 = none, 1 = single, 2 = double,
    //                  33 = single accounting, 34 = double accounting
    procedure SetFontUnderline(UnderlineStyle: Byte);
    property HasFontUnderline: Boolean;
    property FontUnderline: Byte;

    // Built-in number format id
    procedure SetNumFormatId(Id: Word);
    property HasNumFormatId: Boolean;
    property NumFormatId: Word;
  end;

Wire format

The BIFF8 writer appends a non-empty DXF block to the CF12 record whenever the rule's Style has at least one override set. The DXF block uses the public XFProp array layout (cxfp + per-property type / size / data tuples). Colour slots emit xclrType=2 for RGB or xclrType=3 for theme. The reader populates the same property bag from incoming Excel-saved CF12 blobs (v2.35.1+).

Default behaviour is unchanged for rules that don't opt into a style — cbdxf = 0 is emitted, identical to v2.34.0, so existing data bar / colour scale / icon set rules render exactly as before. Unknown xfPropType values in incoming DXF blobs are skipped rather than rejected, so newer Excel files using property types not yet recognised by this release still load (the raw bytes remain in DxfBlob on the parent rule for inspection or future round-trip support).

Example

// Data bar with a Style override: white bold font color over the dark bar fill.
with Sheet.AddCondFormatDataBar('A1:A10', $00B22222).Style do
begin
  SetFontColor($00FFFFFF);   // RGB white
  SetFontBold(True);
end;

// 3-color scale where the mid stop uses theme color 4 lightened 50%.
with Sheet.AddCondFormatColorScale3('B1:B10',
  $000000FF, $0000FFFF, $0000FF00).Style do
  SetFillBgColorTheme(4, 0.5);

See also

TCondFormat / TCondFormatRule classes
IXLSWorksheet.AddCondFormatDataBar