首页 新闻 会员 周边 捐助

Java HSSFSheet 去掉某列的数据有效性验证

0
悬赏园豆:10 [已关闭问题] 关闭于 2021-09-16 17:41

这个性别我想输入别的值,但是excel会提示我有数据有效性验证,请问怎么去掉这个验证,我想要有下拉列表的同时还能可以支持手动输入。

以下是代码

private int createAddressList1(String[] zdxmcList, String[] zdmcList, HSSFSheet dataSheet, HSSFSheet hiddenSheet, int constraintIndex, int rangeIndex) {
int startConstraintIndex = constraintIndex + 1;
int len = zdxmcList.length;
for (int i = 0; i < len; ++i) {
String zdxmc = zdxmcList[i];// 字典项名称
// String zdxbm = zdxbmList[i];// 字典项编码

        HSSFRow row = hiddenSheet.createRow(constraintIndex);
        HSSFCell cell = row.createCell(0);
        cell.setCellValue(new HSSFRichTextString(zdxmc));

        HSSFCell cell2 = row.createCell(1);
        cell2.setCellValue(new HSSFRichTextString(zdmcList[i]));

        constraintIndex++;
    }
    int endConstraintIndex = constraintIndex + 1;

    CellRangeAddressList regions = new CellRangeAddressList(FIRST_DATA_ROW, FIRST_DATA_ROW + Constants.ROW_LIMIT - 1, rangeIndex, rangeIndex);
    DVConstraint constraint = DVConstraint.createFormulaListConstraint("INDIRECT(\"" + HIDDEN_SHEET_NAME + "!$A$" + startConstraintIndex + ":$A$" + endConstraintIndex + "\")");
    HSSFDataValidation dataValidation = new HSSFDataValidation(regions, constraint);
    dataSheet.addValidationData(dataValidation);

    return constraintIndex;
}
曾曾曾zzq的主页 曾曾曾zzq | 初学一级 | 园豆:97
提问于:2021-09-16 16:37
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册