เอกสาร HotXLS

เมธอด AddCondFormatDataBar

เพิ่มกฎการจัดรูปแบบตามเงื่อนไข Data Bar ของ Excel 2007+ เหนือช่วงเซลล์ คืนค่า TCondFormatRule ใหม่เพื่อให้สามารถปรับแต่งแต่ละจุดหยุดได้ก่อนบันทึก ภายในสร้างบล็อก CONDFMT12 และระเบียน CF12 เมื่อบันทึก BIFF8; สำหรับผลลัพธ์ XLSX กฎเดียวกันจะแสดงผ่านองค์ประกอบ OOXML <cfRule type="dataBar"> (ใช้งานได้ตั้งแต่ v2.34.0)

ไวยากรณ์

function AddCondFormatDataBar(const ARange: WideString;
  AColor: LongWord;
  AMinKind: TXLSCfValueKind = cfvMinOfRange; const AMinValue: WideString = '';
  AMaxKind: TXLSCfValueKind = cfvMaxOfRange; const AMaxValue: WideString = ''): TCondFormatRule;
ARange WideString. Sqref สตริง, e.g.'A1:A10'หรือ'B2:C20'
AColor LongWord. Bar พื้นเติม สี ใน Delphi BGR รูปแบบ (R ใน low byte). สำหรับ blue พื้นเติม ใช้$00FF0000; สำหรับ green$0000FF00
AMinKind / AMaxKind TXLSCfValueKind. Threshold types: cfvNumber, cfvMinOfRange, cfvMaxOfRange, cfvPercent, cfvPercentile, cfvFormula, cfvAutoMin, cfvAutoMax. Defaults map min→cfvMinOfRange และ max→cfvMaxOfRange, ที่ตรงกัน Excel's ค่าเริ่มต้น "อัตโนมัติ" bar bounds
AMinValue / AMaxValue WideString. Threshold literal (numeric text for cfvNumber/cfvPercent/cfvPercentile, A1-ช่วง or สูตร text for cfvFormula). Ignored for cfvMinOfRange / cfvMaxOfRange / cfvAutoMin / cfvAutoMax

ตัวอย่าง

ตัวอย่างนี้เพิ่ม data bar สีน้ำเงินเหนือ A1:A10 โดยใช้ขอบเขตค่าต่ำสุด/สูงสุดของช่วงเริ่มต้น

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

ดูเพิ่มเติม