poi 데이터 유효성 (아래 목록)
1996 단어 드롭다운 목록
public class Test {
public static void main(String[] args) {
FileInputStream in = null;
String outputPath = null;
try {
// Workbook
in = new FileInputStream("c:/temp.xlsx");
Workbook workbook = WorkbookFactory.create(in);
Sheet sheet =workbook.getSheetAt(1);
Row row = sheet.getRow(3);
Cell cell = row.getCell(7);
String[] textList = { " 1", " 2" };
sheet.addValidationData(setDataValidation(sheet,textList, 3,3, 7, 7));
cell.setCellValue(" 1");
FileOutputStream out = new FileOutputStream("c:/aaa.xlsx");
workbook.write(out);
out.close();
} catch (Exception e) {
e.printStackTrace();
} finally{
try {
if(in != null){
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static DataValidation setDataValidation(Sheet sheet,String[] textList, int firstRow, int endRow, int firstCol, int endCol) {
DataValidationHelper helper = sheet.getDataValidationHelper();
//
DataValidationConstraint constraint = helper.createExplicitListConstraint(textList);
// DVConstraint constraint = new DVConstraint();
constraint.setExplicitListValues(textList);
// 。
// : 、 、 、
CellRangeAddressList regions = new CellRangeAddressList((short) firstRow, (short) endRow, (short) firstCol, (short) endCol);
//
DataValidation data_validation = helper.createValidation(constraint, regions);
//DataValidation data_validation = new DataValidation(regions, constraint);
return data_validation;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
AppCan 드롭다운 목록 새로 고침프론트 데스크 호출 여기서 주의해야 할 것은 전달하는 매개 변수는 하나의 방법이므로 매개 변수를 가지고 전달하지 마라. 그렇지 않으면 실행될 것이다....
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.