2.1K Star 9.2K Fork 2.7K

悟耘开源 / easypoi

 / 详情

模板导出.xlsx的Excel,使用!if:指令,会出现删除列报错

待办的
缺陷
创建于  
2023-11-03 14:05

cell.setCellValue("");请将这句代码移至删除之前。 @jueyue @dbinary 麻烦修改一下,并更新一下 easypoi-base,这里急用

/**
     * 先判断删除,省得影响效率
     *
     * @param sheet
     * @param map
     * @throws Exception
     */
    private void deleteCell(Sheet sheet, Map<String, Object> map) throws Exception {
        Row  row   = null;
        Cell cell  = null;
        int  index = 0;
        while (index <= sheet.getLastRowNum()) {
            row = sheet.getRow(index++);
            if (row == null) {
                continue;
            }
            for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) {
                cell = row.getCell(i);
                if (row.getCell(i) != null && (cell.getCellType() == CellType.STRING
                        || cell.getCellType() == CellType.NUMERIC)) {
                    cell.setCellType(CellType.STRING);
                    String text = cell.getStringCellValue();
                    if (text.contains(IF_DELETE)) {
                      cell.setCellValue("");
                        if (Boolean.valueOf(
                                eval(text.substring(text.indexOf(START_STR) + 2, text.indexOf(END_STR))
                                        .trim(), map).toString())) {
                            PoiSheetUtil.deleteColumn(sheet, i);
                            i--;
                        }
                       
                    }
                }
            }
        }
    }

评论 (1)

彭建勇 创建了缺陷
彭建勇 修改了描述
展开全部操作日志

下载了4.3的源码,修改此文件,引入三个JAR,但不工作

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
Java
1
https://gitee.com/lemur/easypoi.git
git@gitee.com:lemur/easypoi.git
lemur
easypoi
easypoi

搜索帮助