Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/151.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Aspose文档(.NET)中的现有引用表之后插入Aspose表_.net_Insert_Aspose - Fatal编程技术网

在Aspose文档(.NET)中的现有引用表之后插入Aspose表

在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

我在Aspose word文档中引用了现有表

(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担任开发人员宣传员