【发布时间】:2017-03-29 22:40:13
【问题描述】:
在一个 Word 模板文档中,我定义了一个表头,并希望使用 aspose 以编程方式将数据(多行)添加到同一个表中,并且很难做到这一点。
我在网上找到了一些关于这样做的帖子,但它们都是用 JAVA 编写的,并且这些帖子中使用的函数在 VB.Net 中不可用。
getLastRow() 函数在 Table Class 中不存在。(来自上面的帖子)。
【问题讨论】:
标签: vb.net aspose aspose.words
在一个 Word 模板文档中,我定义了一个表头,并希望使用 aspose 以编程方式将数据(多行)添加到同一个表中,并且很难做到这一点。
我在网上找到了一些关于这样做的帖子,但它们都是用 JAVA 编写的,并且这些帖子中使用的函数在 VB.Net 中不可用。
getLastRow() 函数在 Table Class 中不存在。(来自上面的帖子)。
【问题讨论】:
标签: vb.net aspose aspose.words
请使用 LastRow 方法在 VB 中使用 Aspose.Words for .NET 17.3 获取表格的最后一行。请检查完整的代码如下。
我是 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")
【讨论】: