2016-04-25 5 views

答えて

1

ここではJava Apache POIを使用しています。https://poi.apache.org/が見つかりましたが、これはExcelを使用していない限り少し難しいかもしれません。

別のオプションのAsposeのAPIは、このコードは、既存のテーブルに

Document doc = new Document(MyDir + "document.docx"); 
    // Retrieve the first table in the document. 
    Table table = (Table)doc.getChild(NodeType.TABLE, 0, true); 
    // Clone the last row in the table. 
    Row clonedRow = (Row)table.getLastRow().deepClone(true); 
    // Remove all content from the cloned row's cells. This makes the row ready for 
    // new content to be inserted into. 
    for (Cell cell: clonedRow.getCells()) 
{  
     cell.getFirstParagraph().getRuns().clear(); 
     cell.getFirstParagraph().appendChild(new Run(doc,"hello text")); 
} 
// Add the row to the end of the table. 
table.appendChild(clonedRow); 

doc.save(MyDir + "Table.AddCloneRowToTable Out.doc"); 

参考行を追加することになり、ここでhttp://www.aspose.com/

を発見された:ApacheのPOIテーブルを作成するIAMことを利用しhttp://www.aspose.com/community/forums/thread/648997/reg-adding-rows-dynamically-to-the-existing-table-in-the-document.aspx

+0

が、私を要件は、既存のテーブルに行を追加することです。例と共有できます。 –

+0

上記の例で試したところ、1行しか追加できませんでした。 –

+0

いくつの行を追加したいですか? forループを使用する –

関連する問題