String[] strs3 = new String[]{"是", "否"};
DataValidationHelper helper = sheet1.getDataValidationHelper();//设置下拉框
CellRangeAddressList addressList = new CellRangeAddressList(1, 1000, 4,4);
DataValidationConstraint constraint = helper.createExplicitListConstraint(strs3);
DataValidation dataValidation = helper.createValidation(constraint, addressList);
if (dataValidation instanceof XSSFDataValidation) {
dataValidation.setSuppressDropDownArrow(true);
dataValidation.setShowErrorBox(true);
} else {
dataValidation.setSuppressDropDownArrow(false);
}
sheet1.addValidationData(dataValidation);
java导出 excel 带下拉框
最新推荐文章于 2025-03-11 10:21:35 发布