我正在尝试使用以下代码使用POI在Excel中创建下拉列表。它会在A1单元格中产生下拉。但我想在任何细胞中创造。下面代码中的下拉创建与特定单元格无关。
DataValidation dataValidation = null;
DataValidationConstraint constraint = null;
DataValidationHelper validationHelper = null;
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet1 = (XSSFSheet) wb.createSheet("sheet1");
validationHelper = new XSSFDataValidationHelper(sheet1);
CellRangeAddressList addressList = new CellRangeAddressList(0, 7, 0,0);
constraint = validationHelper.createExplicitListConstraint(new String[]{"SELECT", "10", "20", "30"});
dataValidation = validationHelper.createValidation(constraint, addressList);
dataValidation.setSuppressDropDownArrow(true);
sheet1.addValidationData(dataValidation);
FileOutputStream fileOut = new FileOutputStream("c:/drop-down.xlsx");
wb.write(fileOut);
fileOut.close();
有人可以指出我的步骤。