我正在通过java代码构建动态下拉列表,它工作得很好。我正在运行的代码是:
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Data Validation");
XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper(sheet);
XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint)
dvHelper.createExplicitListConstraint(new String[]{"0000011", "0000021", "0000031"});
CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0);
XSSFDataValidation validation = (XSSFDataValidation)dvHelper.createValidation(
dvConstraint, addressList);
validation.setShowErrorBox(true);
validation.setSuppressDropDownArrow(true);
sheet.addValidationData(validation);
下拉菜单正常出现,但是当我从下拉菜单中选择任何一个值时,00000
会自动删除并且只显示 11,但我希望0000011
从下拉菜单中选择值。
drop 值显示为,0000011
但在选择后显示11
。可能是如果我们可以将单元格类型更改为文本会有所帮助或其他方式,但如何做到这一点?