0
テーブルを含むWordテンプレートがあります(3列と1行)。私はJavaで任意のAPIを使用してこのテーブルにさらに行を追加したいと思います。 Word 2010テンプレートで既存のテーブルに行を追加することはできますか?私たちは既存のテーブルに複数の行を追加できますか?
テーブルを含むWordテンプレートがあります(3列と1行)。私はJavaで任意のAPIを使用してこのテーブルにさらに行を追加したいと思います。 Word 2010テンプレートで既存のテーブルに行を追加することはできますか?私たちは既存のテーブルに複数の行を追加できますか?
ここでは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
が、私を要件は、既存のテーブルに行を追加することです。例と共有できます。 –
上記の例で試したところ、1行しか追加できませんでした。 –
いくつの行を追加したいですか? forループを使用する –