如何使用POI在Excel中为多列创建不同的下拉列表?我已尝试使用以下代码,但它不起作用:
{
CellRangeAddressList addressList =
new CellRangeAddressList(1,10,columnIndexFromHeaderList,columnIndexFromHeaderList);
DVConstraint dvConstraint =
DVConstraint.createExplicitListConstraint(stringArray);
dataValidation = new HSSFDataValidation(addressList,dvConstraint);
dataValidation.setSuppressDropDownArrow(false);
}
答案 0 :(得分:1)
也许你还没有在表格中添加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 );
}