首页 > 解决方案 > Apache POI PPTX - 如何克隆表中的一行

问题描述

我正在尝试添加以下代码来克隆现有行,但新行有单元格,但文本段落的大小显示为 0。

 private XSLFTableRow cloneRow(XSLFTableRow templateRow , XSLFTable tble) {
    
    XSLFTableRow nwRow = tble.addRow();
   
    for (int c = 0; c < templateRow.getCells().size(); c++) {
        nwRow.addCell();
    //  nwRow.getCells().get(c).getXmlObject().set(templateRow.getCells().get(c).getXmlObject());
        
   }
    nwRow.getXmlObject().set(templateRow.getXmlObject().copy());
    
    System.out.println("in new row");
    for(XSLFTableCell tc : nwRow.getCells()) {
        System.out.println(tc.getTextParagraphs().size());
    }
    
    return nwRow;
}

标签: javaapache-poipowerpoint

解决方案


推荐阅读