Note: XSSF Datavalidationhelper, also known as: Xssfdatavalidationconstraint (4, Operatortype, Formula1, FORMULA2) There is bug,hssf* no problem, POI 3.8-poi3.12 have tried, all have this problem
/** * Set ExcelSheet data fill validity constraint * @param sheet current sheet * @param validationtype Authentication type * @param operatortype operator * @pa Ram RowIndex Row index * @param colindex column index * @param vMin min * @param vMax max * @param errortitle Error tip title * @param ERRORMSG error message */public static void Setdatavalidationcheck (Sheet Sheet, int validationtype, int operatortype, int RowIndex, int colindex, string vMin, String VMax, String errortitle, String errormsg) {if (Null==sheet | | rowindex<0 ||
Colindex <0) {return; }//Two values are null returns vMin = NULL = = VMin?
"": Vmin.trim (); Vmax = NULL = = Vmax?
"": Vmax.trim ();
if ("". Equals (VMin) && "". Equals (VMax)) {return;
}//Datavalidationhelper Dvhelper = Sheet.getdatavalidationhelper ();
Datavalidationconstraint dvconstraint = null; if (ValidationType = = DataValidationConstraint.ValidationType.TEXT_LENGTH) {Dvconstraint =
Dvhelper.createtextlengthconstraint (Operatortype, VMin, VMax); } else if (ValidationType = = DatAValidationConstraint.ValidationType.DECIMAL) {dvconstraint = Dvhelper.createdecimalconstraint (Operatortype, VMin,
VMAX); } else if (ValidationType = = DataValidationConstraint.ValidationType.INTEGER) {dvconstraint = Dvhelper.createintegerco
Nstraint (Operatortype, VMin, VMax); } else if (ValidationType = = DataValidationConstraint.ValidationType.DATE) {dvconstraint = Dvhelper.createdateconstrai
NT (Operatortype, vMin, vMax, NULL); } else if (ValidationType = = DataValidationConstraint.ValidationType.TIME) {dvconstraint = Dvhelper.createtimeconstrai
NT (Operatortype, VMin, VMax);
} if (null = = Dvconstraint) {return; } cellrangeaddresslist AddressList = new Cellrangeaddresslist (RowIndex, Getlastrowindex (Sheet.getworkbook ()),
Colindex, Colindex);
datavalidation validation = dvhelper.createvalidation (Dvconstraint, AddressList);
Set error message Validation.setsuppressdropdownarrow (TRUE);
Validation.setshowerrorbox (TRUE); Setdatavalidationerrormessage (ValidatiOn, ErrorTitle, errormsg);
Sheet.addvalidationdata (validation); }
The official does not know whether the bug has been found, did not find the POI forum published.