Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
oh-wukai opened this issue Mar 26, 2024 · 0 comments
Open

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

oh-wukai opened this issue Mar 26, 2024 · 0 comments

Comments

@oh-wukai
Copy link

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;//删除之后要往上挪一行,然后加上跳过新建的行数 } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant