如何在HSSFDataValidation中设置公式的单元名称

时间:2017-05-13 10:13:20

标签: excel validation apache-poi hssf hssfworkbook

我希望两个单元格之间的单元格值。 我使用HSSFDataValidation进行集验证,以便通过apache poi创建excel文件,但执行时出错。

  

源代码:

HSSFDataValidationHelper dvHelper = new HSSFDataValidationHelper(sheet);
DVConstraint dvConstraint =(DVConstraint) dvHelper.createNumericConstraint
             (DataValidationConstraint.ValidationType.DECIMAL,
              DataValidationConstraint.OperatorType.BETWEEN,
              "G3", 
              "H3");
CellRangeAddressList  addressList=new CellRangeAddressList (2,rowNum,8,8);
DataValidation validation =dvHelper.createValidation(dvConstraint, addressList);
validation.setSuppressDropDownArrow(false);
validation.setShowErrorBox(true);
sheet.addValidationData(validation);
  

错误:

The supplied text 'G3' could not be parsed as a number 

1 个答案:

答案 0 :(得分:0)

将此格式用于公式:"=$G$3""=$H$3"