jeecgboot / autopoi

AutoPOI 功能如同名字auto,追求的就是自动化,让一个没接触过poi的人员,可以傻瓜化的快速实现Excel导入导出、Word模板导出、可以仅仅5行代码就可以完成Excel的导入导出。
http://www.jeecg.com
Apache License 2.0
460 stars 199 forks source link

word含表格模板导出,占位符未删除 #108

Open oh-wukai opened 4 months ago

oh-wukai commented 4 months ago

1.word中的表格占位符必须写成 {{$fe:变量}},否则报错。原因是判断是否需要循环方法【checkThisTableIsNeedIterator()】对【$fe:】进行校验; 2.使用ExcelListEntity作为数据载体,渲染后占位符所在行不会删除; 3.使用List作为数据载体,会删除占位符所在行,但无法定义第一列占位符,导致第一列无法填充数据 4.关键方法如下: private void parseThisTable(XWPFTable table, Map<String, Object> map) throws Exception { XWPFTableRow row; List<XWPFTableCell> cells; Object listobj; for (int i = 0; i < table.getNumberOfRows(); i++) { row = table.getRow(i); cells = row.getTableCells(); //begin-------author:liusq------date:20210129-----for:-------poi3升级到4兼容改造工作【重要敏感修改点】-------- listobj = checkThisTableIsNeedIterator(cells.get(0), map); if (listobj == null) { parseThisRow(cells, map); } else if (listobj instanceof ExcelListEntity) { new ExcelEntityParse().parseNextRowAndAddRow(table, i, (ExcelListEntity) listobj); i = i + ((ExcelListEntity) listobj).getList().size() - 1;//删除之后要往上挪一行,然后加上跳过新建的行数 } else { ExcelMapParse.parseNextRowAndAddRow(table, i, (List) listobj); i = i + ((List) listobj).size() - 1;//删除之后要往上挪一行,然后加上跳过新建的行数 } }