<κλάση header="doc-nav" aria-label="Πλοήγηση τεκμηρίωσης">
Τεκμηρίωση HotXLS
<κλάση nav="doc-links">
Περιεχόμενα
Αρχική
Επισκόπηση
IXLSInterior
XLS color model
<κλάση div="nav topic-quick-nav" aria-label="Topic shortcuts">
Αρχική
Περιεχόμενα
Επισκόπηση
SetThemeColor method (Interior)
<κλάση div="indent">
<κλάση div="txt">
Sets the cell shading fill (foreground) color to one of the 12 Office theme color slots with an optional tint adjustment. Companion of Interior.Color for callers who want to address Office theme colors directly (so Excel can re-tint the cell with the workbook's theme palette) instead of pinning a fixed RGB. Available since v2.61.0 (chart backlog wave D phase 4)
Σύνταξη
<κλάση div="indent">
<κλάση pre="code">
procedure SetThemeColor(ThemeIdx: Word; Tint: Double);
Παράμετροι
<κλάση div="indent">
<κλάση div="txt">
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
<κλάση div="txt">
Tint — spec-style lighter/darker adjustment in the range -1.0 .. +1.0
0.0 uses the theme slot's base color; negative values darken (HSL luminance toward 0),
positive values lighten (HSL luminance toward 1). The HotXLS reader encodes this as a Q15 signed
integer in the FullColorExt.nTintShade field of the XFExt record
Παρατηρήσεις
<κλάση div="indent">
<κλάση div="txt">
The setter walks two paths so the same cell renders correctly in both Excel 2007+ and Excel 2003:
- Indexed icv on the XF record (legacy) — the theme + tint resolves through the workbook's BIFF theme palette into an RGB, which then picks the closest 56-color palette index. Excel 97-2003 sees this approximation when the file is opened
- FullColorExt slot on XFExt $087D (Excel 2007+) — the writer emits a rich-color side record with
xclrType=3 (theme), xclrValue=ThemeIdx, and nTintShade derived from Tint. Excel 2007+ uses this to recover the exact theme intent and 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
<κλάση div="txt">
Cells set via SetThemeColor round-trip on load: Interior.Color returns the resolved RGB (theme + tint applied through the BIFF theme palette) so callers always see a concrete LongWord value
<κλάση div="txt">
Custom theme palettes set in Excel via Page Layout → Colors survive load and save through the BIFF8 Theme ($0892) record, so any caller-side SetThemeColor reference resolves through the workbook's actual theme rather than the default Office scheme
Παράδειγμα
<κλάση div="indent">
<κλάση div="txt">
Fills the header row with accent1 and tags warning cells with a 50% lightened red accent (accent2 + 0.5 tint)
<κλάση pre="code">
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;
Δείτε επίσης
<κλάση div="indent">
<κλάση div="txt">
διεπαφή IXLSInterior
IXLSInterior.SetPatternThemeColorμέθοδος
IXLSFont.SetThemeColorμέθοδος
IXLSBorder.SetThemeColorμέθοδος
XlsApplyThemeColorToDrawing συνάρτηση (drawings)
Classic XLS color model
<κλάση footer="reference-footer">Copyright © 2010-2026 losLab Software