HotXLS Docs

AddCondFormatDataBar method

Adds an Excel 2007+ Data Bar conditional formatting rule over a cell range, returning the new TCondFormatRule so the rule's per-stop tuning can be refined before save. Internally creates a CONDFMT12 block and a CF12 record on BIFF8 save; for XLSX output the same rule is rendered through the OOXML <cfRule type="dataBar"> element. (Available since v2.34.0.)

Syntax

function AddCondFormatDataBar(const ARange: WideString;
  AColor: LongWord;
  AMinKind: TXLSCfValueKind = cfvMinOfRange; const AMinValue: WideString = '';
  AMaxKind: TXLSCfValueKind = cfvMaxOfRange; const AMaxValue: WideString = ''): TCondFormatRule;
ARange WideString. Sqref string, e.g. 'A1:A10' or 'B2:C20'.
AColor LongWord. Bar fill colour in Delphi BGR format (R in the low byte). For a blue fill use $00FF0000; for green $0000FF00.
AMinKind / AMaxKind TXLSCfValueKind. Threshold types: cfvNumber, cfvMinOfRange, cfvMaxOfRange, cfvPercent, cfvPercentile, cfvFormula, cfvAutoMin, cfvAutoMax. Defaults map min→cfvMinOfRange and max→cfvMaxOfRange, matching Excel's default "automatic" bar bounds.
AMinValue / AMaxValue WideString. Threshold literal (numeric text for cfvNumber/cfvPercent/cfvPercentile, A1-range or formula text for cfvFormula). Ignored for cfvMinOfRange / cfvMaxOfRange / cfvAutoMin / cfvAutoMax.

Example

This example adds a blue data bar over A1:A10 using the default min/max-of-range bounds.

Sheet.AddCondFormatDataBar('A1:A10', $00FF0000);

See also