Imposta il colore di riempimento dell'ombreggiatura (primo piano) della cella su uno dei 12 slot di colore del tema Office con una regolazione facoltativa della tinta. Controparte di
Interior.Color per i chiamanti che vogliono indirizzare direttamente i colori del tema Office (così Excel può ritintare la cella con la palette dei temi della cartella di lavoro) invece di fissare un RGB statico. Disponibile dalla v2.61.0 (chart backlog wave D phase 4)
Sintassi
procedure SetThemeColor(ThemeIdx: Word; Tint: Double);
Parametri
ThemeIdx — 0-based theme slot:
0=lt1, 1=dk1, 2=lt2, 3=dk2,
4..9=accent1..accent6, 10=hlink, 11=foHlink
Matches the standard Office theme order used by the XLSX side
Tint — spec-style lighter/darker adjustment in the range -1.0 .. +1.0
0.0 usa il colore di base dello slot del tema; i valori negativi scuriscono (luminanza HSL verso 0),
i valori positivi schiariscono (luminanza HSL verso 1). Il reader HotXLS codifica questo come un intero
con segno Q15 nel FullColorExt.nTintShade field of the XFExt record
Osservazioni
The setter walks two paths so the same cell renders correctly in both Excel 2007+ e Excel 2003:
- Indexed icv on the XF record (legacy) — tema + tinta vengono risolti attraverso la palette dei temi BIFF della cartella di lavoro fino a un RGB, che poi seleziona l'indice più vicino nella palette a 56 colori. Excel 97-2003 vede questa approssimazione quando il file viene aperto
- FullColorExt slot on XFExt $087D (Excel 2007+) — the writer emits a rich-color side record with
xclrType=3 (theme), xclrValue=ThemeIdx, e nTintShade derived from Tint. Excel 2007+ uses this to recover the exact theme intent e re-tints the cell whenever the workbook theme palette changes — the same backward-compatibility trick Microsoft uses when "Save As" downgrades a theme-styled .xlsx to .xls
Cells set via
SetThemeColor round-trip on load:
Interior.Color restituisce il valore RGB risolto (tema + tinta applicati attraverso la palette dei temi BIFF) così i chiamanti vedono sempre un valore LongWord concreto
Custom theme palettes set in Excel via Page Layout → Colors survive load e save through the BIFF8 Theme ($0892) record, so any caller-side SetThemeColor riferimento si risolve attraverso il tema effettivo della cartella di lavoro invece dello schema Office predefinito
Esempio
Fills the header row with accent1 e tags warning cells with a 50% lightened red accent (accent2 + 0.5 tint)
var
Header : IXLSRange;
Warnings : IXLSRange;
begin
Header := Workbook.Sheets[1].Range['A1', 'G1'];
Header.Interior.SetThemeColor(4, 0.0); // accent1, base shade
Warnings := Workbook.Sheets[1].Range['G2', 'G20'];
Warnings.Interior.SetThemeColor(5, 0.5); // accent2, 50% lighter
Workbook.SaveAs('ThemeFills.xls', xlExcel97);
end;
Vedere also