TXLSXDataValidations manages Excel input constraints for TXLSXWorksheet.DataValidations and each rule is a TXLSXDataValidation
Declarations
function Add(const ARange: WideString; AType: TXLSXDataValidationType; AOp: TXLSXDvOperator; const AFormula1: WideString): Integer;
function Add(const ARange: WideString; AType: TXLSXDataValidationType; AOp: TXLSXDvOperator; const AFormula1, AFormula2: WideString): Integer;
function AddList(const ARange, AItems: WideString): Integer;
procedure TXLSXDataValidation.SetPrompt(const ATitle, AText: WideString);
procedure TXLSXDataValidation.SetError(const ATitle, AText: WideString; AStyle: TXLSXDvErrorStyle = xlsxDvErrStop);
สมาชิกกฎ
| ช่วงและ ValidationType | เซลล์ปลายทางและประเภทการตรวจสอบความถูกต้องแบบจำนวนเต็ม ทศนิยม รายการ วันที่ เวลา ความยาวข้อความ หรือแบบกำหนดเอง |
| Op, Formula1 และ Formula2 | ตัวดำเนินการเปรียบเทียบและนิพจน์เกณฑ์หนึ่งหรือสองรายการ |
| AllowBlank | อนุญาตให้มีค่าว่างได้ในขณะที่ยังคงรักษากฎการตรวจสอบข้อมูลไว้ |
| PromptTitle และ Prompt | ข้อความอินพุตที่แสดงเมื่อเลือกเซลล์เป้าหมาย |
| ErrorTitle, ErrorMessage และ ErrorStyle | การแจ้งเตือนข้อมูลที่ป้อนไม่ถูกต้อง รวมถึงไอคอนหยุด, คำเตือน หรือข้อมูล |
| ShowDropDown | ควบคุมว่าจะให้การตรวจสอบรายการแสดงลูกศรเลือกหรือไม่ |
| ImeMode | โหมดอินพุต OOXML IME สำหรับไคลเอนต์ CJK ที่รองรับ |
ตัวอย่าง
var Index: Integer;
begin
Index := Sheet.DataValidations.AddList('D2:D100', 'New,Active,Closed');
Sheet.DataValidations[Index].SetPrompt('Status', 'เลือกสถานะที่อนุญาต');
Sheet.DataValidations[Index].SetError('สถานะไม่ถูกต้อง', 'เลือกค่าจากรายการ');
end;
ดูเพิ่มเติม