我需要检查用户是否在单元格 A1:A10 中输入了有效数字。在 Excel 中,我会选择单元格,然后创建自定义验证器并将公式设置为 =isNumber("$A$1:$A10") 尝试使用 POI 执行此操作让我陷入困境:这是我尝试过的:
CellRangeAddressList addressList = new CellRangeAddressList(0, 10, 0, 0);
XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper(sheet);
DataValidationConstraint customConstraint = dvHelper.createCustomConstraint("isNumber(\"$A$0:$A$10\"");
XSSFDataValidation validation = (XSSFDataValidation)dvHelper.createValidation(customConstraint, addressList);
validation.setShowErrorBox(true);
sheet.addValidationData(validation);
当我尝试在 Excel 中打开它时,出现错误,并且 Excel 禁用了验证
在此先感谢-anish