小编Zao*_*osz的帖子

java Apache POI Word现有表插入带有单元格样式和格式的行

我是Apache POI中的一个重要人物,并希望在单词tamplate文件中扩展一些存在的表.如果我使用下面的代码,表格将扩展为行位,新行的单元格创建正常样式.

我的目标是细胞具有相同的表格细胞样式等(字体,有,高...)

    XWPFDocument doc = new XWPFDocument(openFile(fileName));
    XWPFTable tbl = doc.getTableArray(tableIndex);
    XWPFTableRow lastRow = tbl.getRows().get(tbl.getNumberOfRows() - 1);
    cellCounter = lastRow.getTableICells().size(); 
    XWPFTableRow newRow = tbl.createRow(); 
    for (int i = 0; i < data.size() && cellCounter <= data.size(); i++) {         
    String text = data.get(i);
        XWPFTableCell cell = newRow.getCell(i);
        if (cell != null) {
            cell.setText(text);
        }
    }
Run Code Online (Sandbox Code Playgroud)

感谢您的回答.R.

java ms-word apache-poi

1
推荐指数
1
解决办法
6949
查看次数

标签 统计

apache-poi ×1

java ×1

ms-word ×1