如何使用POI在Excel中为多列创建不同的下拉列表?我已经尝试使用以下代码,但无法正常工作:
{
CellRangeAddressList addressList =
new CellRangeAddressList(1,10,columnIndexFromHeaderList,columnIndexFromHeaderList);
DVConstraint dvConstraint =
DVConstraint.createExplicitListConstraint(stringArray);
dataValidation = new HSSFDataValidation(addressList,dvConstraint);
dataValidation.setSuppressDropDownArrow(false);
}
最佳答案
也许您还没有在工作表中添加dataValidation ...请添加它...希望这会起作用。
{
CellRangeAddressList addressList =
new CellRangeAddressList(1,10,columnIndexFromHeaderList,columnIndexFromHeaderList);
DVConstraint dvConstraint =
DVConstraint.createExplicitListConstraint(stringArray);
dataValidation = new HSSFDataValidation(addressList,dvConstraint);
dataValidation.setSuppressDropDownArrow(false);
sheet.addValidationData(dataValidation );
}