(Java操作Word--Aspose Word) 替换指定单元内容

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chenpengjia006/article/details/81477181
        Document srcDoc = new Document(srcDocPath);
        //获取第一个表格
        Table table = (Table)srcDoc.getChild(NodeType.TABLE, 0, true);
        RowCollection rows = table.getRows();
        for (int i = 1; i < rows.getCount(); i++) {
            Row row = rows.get(i);
            Cell cell = row.getCells().get(5);
            if(null != cell ){
                    String text = row.getCells().get(3).getText();
                    if(null != text && !"".equals(text)){
                    //设置新内容
                    cell.getFirstParagraph().getRuns().get(0).setText("");
                    }
            }
        }

猜你喜欢

转载自blog.csdn.net/chenpengjia006/article/details/81477181