一.导出 报表EXECL导出 单元格下拉框的开发
- 简单下拉框,一般下拉框字符数不超过255个字符
private static DataValidation setFewDataValidation(Sheet sheet, String[] textList, int firstRow, int endRow, int firstCol, int endCol) {
DataValidationHelper helper = sheet.getDataValidationHelper();
//加载下拉列表内容
DataValidationConstraint constraint = helper.createExplicitListConstraint(textList);
constraint.setExplicitListValues(textList);
//设置数据有效性加载在哪个单元格上。四个参数分别是:起始行、终止行、起始列、终止列
CellRangeAddressList regions = new CellRangeAddressList((short) firstRow, (short) endRow, (short) firstCol, (short) endCol);
//数据有效性对象
return helper.createValidation(constraint, regions);
}
DataValidation dataValidation = setFewDataValidation(Sheet sheet, String[] textList, int firstRow, int endRow, int firstCol, int endCol);
sheet.addValidationData(dataValidation);
2.复杂下拉框 超过255个字符
需要建立单独的sheet页来存储下拉框值,并隐藏