HotXLS Belgeleri

TCondFormat / TCondFormatRule and CF12 spec classes

Birim: lxCondFormat

Excel 2007+ uzantı kurallarını destekleyen BIFF8 (.xls) koşullu biçimlendirme ailesi. TXLSWorksheet keeps a collection of TCondFormat entries; each entry covers one or more cell ranges and holds an ordered list of TCondFormatRule nesnesi; her kural ya eski bir hücre değeri kuralı ya da CF12 Veri Çubuğu / Renk Ölçeği / Simge Kümesi kuralıdır. Dört Sheet.AddCondFormat* entry points (DataBar, ColorScale2, ColorScale3, IconSet) construct rules of the correct subtype. Available since v2.34.0

Threshold kind enumeration

type
  TXLSCfValueKind = (
    cfvNumber      = 0,
    cfvMinOfRange  = 1,
    cfvMaxOfRange  = 2,
    cfvPercent     = 3,
    cfvPercentile  = 4,
    cfvFormula     = 5,
    cfvAutoMin     = 6,  // Excel 2010+ data-bar only
    cfvAutoMax     = 7); // Excel 2010+ data-bar only

Icon-set family enumeration

type
  TXLSIconSetType = (
    icsArrows3, icsArrows3Gray, icsFlags3,
    icsTrafficLights3, icsTrafficLightsRimmed3, icsSigns3,
    icsSymbols3, icsSymbolsUncircled3,
    icsArrows4, icsArrows4Gray, icsRedToBlack4,
    icsRatings4, icsTrafficLights4,
    icsArrows5, icsArrows5Gray,
    icsRatings5, icsQuarters5);

17 temel Excel 2007 simge ailesi. Sayısal durak sayısı (3, 4 veya 5), enum adında kodlanır

Threshold value (cfvo)

type
  TXLSCfValue = class
    constructor Create(AKind: TXLSCfValueKind;
      const AValue: WideString; AColor: LongWord);
    procedure SetThemeColor(ThemeId: Word; Tint: Single); // v2.43.0+
    procedure ClearThemeColor;                            // v2.43.0+
    property Kind: TXLSCfValueKind;
    property Value: WideString;       // numeric literal or formula text
    property Color: LongWord;         // BGR RGB for ColorScale stops
    property IsThemeColor: Boolean;    // v2.43.0+ true = theme mode active
    property ThemeColorId: Word;       // v2.43.0+ theme palette index
    property ThemeColorTint: Single;   // v2.43.0+ -1.0 .. 0.0 .. +1.0
  end;

Data bar payload

type
  TXLSDataBarSpec = class
    procedure SetThemeColor(ThemeId: Word; Tint: Single); // v2.43.0+ — opt bar fill into theme mode
    procedure ClearThemeColor;                            // v2.43.0+ — revert to RGB Color
    property Min: TXLSCfValue;
    property Max: TXLSCfValue;
    property Color: LongWord;         // bar fill
    property ShowValue: Boolean;      // false = hide cell text
    property MinLength: Byte;         // 0..100 percent
    property MaxLength: Byte;         // 0..100 percent
    property IsThemeColor: Boolean;    // v2.43.0+ true = theme mode active
    property ThemeColorId: Word;       // v2.43.0+ theme palette index
    property ThemeColorTint: Single;   // v2.43.0+ -1.0 .. 0.0 .. +1.0
  end;

XLSX theme color round-trip (v2.43.0+)

Veri Çubuğu kuralındaki çubuk dolgu rengi ve Renk Ölçeği kuralındaki durak başına renkler, SetThemeColor(ThemeId, Tint) instead of a frozen RGB. The XLSX writer emits <color theme="N"/> when Tint is exactly 0.0 or <color theme="N" tint="0.5"/> sıfır değilken, Excel'in kendi "en kısa biçim" çıktısıyla eşleşir. Okuyucu her iki öznitelik kombinasyonunu da ayrıştırır ve RGB rgb= path when neither theme nor tint is present. Two modes are mutually exclusive per slot; whichever Set was called last wins IsThemeColor reflects the active mode for inspection

BIFF8 CF12 yalnızca çözümlenmiş RGB rengini saklar — tema modu bu sürümde yalnızca XLSX arka ucunda gidiş-dönüş yapar iconSet rules have no <color> elements so the theme-mode addition does not affect them

Color scale payload

type
  TXLSColorScaleSpec = class
    constructor Create(IsThreeStop: Boolean);
    procedure SetStop(I: Integer; Kind: TXLSCfValueKind;
      const Value: WideString; Color: LongWord);
    property StopCount: Integer;      // 2 or 3
    property Stops[I: Integer]: TXLSCfValue; default;
  end;

Icon set payload

type
  TXLSIconSetSpec = class
    constructor Create(ASetType: TXLSIconSetType);
    procedure SetThreshold(I: Integer; Kind: TXLSCfValueKind;
      const Value: WideString);
    // Per-stop icon override (v2.44.0+).
    procedure SetIconOverride(I: Integer;
      OverrideSet: TXLSIconSetType; IconId: Byte);
    procedure ClearIconOverride(I: Integer);
    property SetType: TXLSIconSetType;
    property Reverse: Boolean;        // reverse the icon order
    property ShowOnly: Boolean;       // true = icon only, hide cell text
    property IconCount: Integer;      // 3, 4 or 5 (derived from SetType)
    property Thresholds[I: Integer]: TXLSCfValue;
    property HasIconOverride[I: Integer]: Boolean;        // v2.44.0+
    property IconOverrideSet[I: Integer]: TXLSIconSetType; // v2.44.0+
    property IconOverrideId[I: Integer]: Byte;             // v2.44.0+
  end;

Per-stop icon override (v2.44.0+)

Simge Kümesi kuralındaki her durak, görüntülenen simgesini 17 yerleşik simge ailesinin herhangi birinden herhangi bir simgeyle geçersiz kılabilir; (OverrideSet, IconId) pair. XLSX emits <cfIcon iconSet="..." iconId="N"/> geçersiz kılınan her durak için. BIFF8 CF12, aile varsayılanı simgeyi işlemeye devam eder; çünkü BIFF8 tel biçiminde durak başına geçersiz kılmaya ayrılmış yuva yoktur — bu, geçerli sürümde yalnızca XLSX'e özgü bir yetenektir. HasIconOverride[i] returns True only for stops that have been explicitly opted in via SetIconOverride; the default-icon stops continue to use the family's stop-position default

Rule

type
  TCondFormatRule = class
    property Kind: TXLSCfKind;
    property cfType: Word;            // CF-record subtype
    property Operator_: Word;         // comparison operator for cellIs
    property DataBar: TXLSDataBarSpec;       // non-nil for Data Bar rules
    property ColorScale: TXLSColorScaleSpec; // non-nil for Color Scale rules
    property IconSet: TXLSIconSetSpec;       // non-nil for Icon Set rules
    property Style: TXLSDxfStyle;        // DXF override; lazy-created (v2.35.0+)
    property DxfBlob: TXLSBlob;       // raw DXF bytes from Parse (v2.35.0+)
    property Priority: Word;          // CF12 ipriority; 0 = writer assigns (v2.45.0+)
  end;

Exactly one of DataBar / ColorScale / IconSet is non-nil per CF12 rule, matching the rule's Kind. Legacy cellIs rules (non-CF12) leave all three nil and use Operator_ + Formula1 / Formula2

The Style özelliği (v2.35.0+) ilk okumada tembel oluşturulur; döndürülen nesnenin sahibi kuraldır ve yıkıcısında serbest bırakılır. HasXxx via the corresponding SetXxx call on Style. The BIFF8 reader keeps the raw bytes in DxfBlob in addition to decoding them into Style (v2.35.1+), so a load-edit-save round-trip reflects any post-load mutation of Style; kullanıcı dokunmazsa kaydedilen dosya, orijinalindeki geçersiz kılmaların aynısını taşır

On BIFF8 CF12 Veri Çubuğu, Renk Ölçeği ve Simge Kümesi kurallarında [MS-XLS], satır içi DXF bloğunun boş olmasını gerektirir. v2.87.4'ten itibaren HotXLS bu kurala uyar: Rule.Style bu üç CF12 türü için .xls kaydederken serileştirilmez. Veri Çubuğu / Renk Ölçeği / Simge Kümesi kuralı yapılandırmasının kendisi, CF12'nin türe özgü kuyruğu aracılığıyla yine de korunur. XLSX koşullu biçimlendirme çıktısı etkilenmez

Container

type
  TCondFormat = class
    procedure ClearRow(row: Integer);
    procedure ClearCol(col: Integer);
    procedure ClearRange(row1, col1, row2, col2: Integer);
    procedure MoveRanges(row1, col1, row2, col2,
      drow, dcol: Integer);
    function  RuleCount: Integer;                // v2.40.0+
    function  Rule(I: Integer): TCondFormatRule;  // v2.40.0+
    property Range[i: Integer]: TCondRange; default;
    property IsEmpty: Boolean;
    property IsExt12: Boolean;       // true = emits CONDFMT12/CF12
    property IsShadowed: Boolean;    // v2.37.0+ — duplicate CONDFMT marker
    property TotalRange: TCondRange; // v2.37.0+ — merged-extent range
  end;

Cross-version shadow detection (v2.37.0+)

Excel-saved files often carry both an Excel 2003 cell-value CONDFMT and an Excel 2007+ CONDFMT12 aynı sqref'i kapsayan — hücre değeri kaydı, eski Excel'in hâlâ işleyebildiği sürümler arası yedek kayıttır. Okuyucu eski girişi IsShadowed = True after detecting an exact bounding-box match on TotalRange, böylece koşullu biçimlendirme koleksiyonunu gezen kullanıcıya dönük kod kopyayı atlayabilir. Yazıcı, Excel 2003 ↔ Excel 2007+ uyumluluğu için kaydetme sırasında her iki kayıt ailesini de yayınlamaya devam eder

Wire format

On BIFF8 SaveAs(xlExcel97), CF12 rules emit CONDFMT12 ($0879) + CF12 ($087A) records alongside the legacy CONDFMT ($01B0) + CF ($01B1) ile Excel 2003 ile çapraz sürüm uyumluluğu sağlar. Okuyucu modern kayıtları tanır ve aynı bellek içi kural modeliyle açığa çıkarır; böylece uzantı kurallı, Excel kaynaklı .xls dosyaları veri kaybı olmadan gidiş-dönüş yapar

Örnek

// Data bar with custom min/max thresholds.
with Sheet.AddCondFormatDataBar('A1:A10', $00FF0000,
  cfvNumber, '0', cfvNumber, '100').DataBar do
begin
  ShowValue := True;
  MinLength := 10;
  MaxLength := 90;
end;

// 3 Arrows icon set, reversed so green points down.
with Sheet.AddCondFormatIconSet('B1:B10', icsArrows3).IconSet do
begin
  Reverse  := True;
  ShowOnly := False;
end;

Ayrıca bkz.

TXLSWorksheet.AddCondFormatDataBar
TXLSWorksheet.AddCondFormatColorScale2
TXLSWorksheet.AddCondFormatColorScale3
TXLSWorksheet.AddCondFormatIconSet
TXLSXConditionalFormat (XLSX side)