Aspose.Word - 在VB.Net

时间:2017-03-29 22:40:13

标签: vb.net aspose aspose.words

在Word模板文档中,我定义了一个表头,并希望使用aspose以编程方式将数据(多行)添加到同一个表中,并且很难做到这一点。

我在网上找到的帖子很少,但是所有帖子都是用JAVA写的,这些帖子中使用的功能在VB.Net中不可用。

https://www.aspose.com/community/forums/thread/648997/reg-adding-rows-dynamically-to-the-existing-table-in-the-document.aspx

Table Class中不存在

getLastRow()函数。(来自上面的帖子)。

有人可以指出我正确的文档或为我的问题提供解决方案。 Missing Width 在此先感谢!

1 个答案:

答案 0 :(得分:1)

请使用LastRow方法使用Aspose.Words for .NET 17.3获取VB中的最后一行表。请检查完整代码如下。

我是Aspose的开发者传道者Tilal Ahmad。

Dim doc As New Document("input.docx")
' Retrieve the first table in the document.
Dim table As Table = DirectCast(doc.GetChild(NodeType.Table, 0, True), Table)
table.FirstRow.RowFormat.HeadingFormat = True
For i As Integer = 1 To 15
' Clone the last row in the table.
Dim clonedRow As Row = DirectCast(table.LastRow.Clone(True), Row)
clonedRow.RowFormat.HeadingFormat = False
' Remove all content from the cloned row's cells. This makes the row ready for
' new content to be inserted into.
For Each cell As Cell In clonedRow.Cells
    cell.FirstParagraph.Runs.Clear() 
    cell.CellFormat.ClearFormatting()
    cell.FirstParagraph.AppendChild(New Run(doc, "hello text"))
Next

' Add the row to the end of the table.

table.AppendChild(clonedRow)
Next

doc.Save("Table.AddCloneRowToTable Out.doc")
相关问题