在Aspose文档(.NET)中的现有引用表之后插入Aspose表
我在Aspose word文档中引用了现有表在Aspose文档(.NET)中的现有引用表之后插入Aspose表,.net,insert,aspose,.net,Insert,Aspose,我在Aspose word文档中引用了现有表 (Table)wordDocument.GetChild(Note.Type.Table, 3, true) 我新建了一个表。是否可以将其插入该引用项之后? 在Aspose API中,我只能找到转到ParentNode,然后使用InsertBefore,但我不明白为什么它不能与引用的表一起使用?您可以使用以下代码在引用的表之后插入一个新表 // Load the document. Document doc = new Document("Tabl
(Table)wordDocument.GetChild(Note.Type.Table, 3, true)
我新建了一个表。是否可以将其插入该引用项之后?
在Aspose API中,我只能找到转到ParentNode,然后使用InsertBefore,但我不明白为什么它不能与引用的表一起使用?您可以使用以下代码在引用的表之后插入一个新表
// Load the document.
Document doc = new Document("Tables.docx");
// Get reference table in the document.
Table referenceTable = (Table)doc.GetChild(NodeType.Table, 1, true);
// Create a new table.
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.StartTable();
// Insert a cell
builder.InsertCell();
builder.Write("This is row 1 cell 1");
// Insert a cell
builder.InsertCell();
builder.Write("This is row 1 cell 2");
builder.EndRow();
builder.EndTable();
// Insert the container after the original.
referenceTable.ParentNode.InsertAfter(table, referenceTable);
// Add a buffer paragraph to ensure the tables stay apart.
referenceTable.ParentNode.InsertAfter(new Paragraph(doc), referenceTable);
doc.Save("Tables_Out.docx");
我在Aspose担任开发人员宣传员