HotXLS Docs

SetPatternThemeColor method (Interior)

Sets the cell pattern (background) colour to one of the 12 Office theme colour slots with an optional tint adjustment. This is the pattern-colour companion of Interior.SetThemeColor — use it together with a non-solid Pattern to render hatch / dotted fills that re-tint when Excel re-applies the workbook theme. Available since v2.61.0 (chart backlog wave D phase 4).

Syntax

procedure SetPatternThemeColor(ThemeIdx: Word; Tint: Double);

Parameters

ThemeIdx — 0-based theme slot (0=lt1, 1=dk1, 2=lt2, 3=dk2, 4..9=accent1..6, 10=hlink, 11=foHlink).
Tint — spec-style lighter/darker adjustment in the range -1.0 .. +1.0. Encoded into FullColorExt.nTintShade as a Q15 signed integer on the XFExt record.

Remarks

Two wires are emitted for every call so the cell renders correctly in both Excel 2007+ and Excel 2003:
Reading back via Interior.PatternColor returns the resolved RGB (theme + tint applied), so callers always see a concrete LongWord.

Example

Renders a striped warning band using the accent1 / accent2 theme slots so the colours track the workbook theme.

var
  Stripes: IXLSRange;
begin
  Stripes := Workbook.Sheets[1].Range['B2', 'B10'];
  Stripes.Interior.Pattern := xlPatternGray25;
  Stripes.Interior.SetThemeColor(4, 0.4);          // fill foreground (accent1, lighter)
  Stripes.Interior.SetPatternThemeColor(5, - 0.25);  // pattern color (accent2, darker)

  Workbook.SaveAs('PatternThemeFills.xls', xlExcel97);
end;

See also