DocumentBuilder documentBuilder = new DocumentBuilder(document); boolean b = documentBuilder.moveToBookmark("table"); NodeCollection tableNodes = document.getChildNodes(NodeType.TABLE, true); int count = tableNodes.getCount(); if (!b && count < 3) { throw new DxBusinessException("500", "配置项表格书签丢失"); } else { for (int i = 0; i < count; i++) { Table table = (Table) tableNodes.get(i); if (table != null) { RowCollection rows = table.getRows(); CellCollection cells = rows.get(0).getCells(); if (cells.getCount() > 1) { String trim = StrUtil.removeAllLineBreaks(cells.get(1).getText().trim()); //配置单表格 if ("图号".equals(trim)) { documentBuilder.moveTo(table.getNextSibling()); table.remove(); i--; count--; } } } } } documentBuilder.insertDocument(tableTemplate, ImportFormatMode.KEEP_SOURCE_FORMATTING);
aspose替换表格
最新推荐文章于 2024-04-29 16:29:40 发布