Reputation: 906
In a Word template document, I have a table header defined and would like to add data (Multiple rows) to the same table programmatically using aspose and having hard time in doing this.
I found few posts on online for doing this but all of them are written JAVA and functions that are used in these posts are not available in VB.Net.
getLastRow() function doesn't exists in Table Class.(from above post).
Can some one point me to right documentation or provide a solution for my problem.
Thanks in Advance!
Upvotes: 0
Views: 1524
Reputation: 939
Please use LastRow method to get last row of table in VB using Aspose.Words for .NET 17.3. Please check complete code as following.
I am Tilal Ahmad, developer evangelist at Aspose.
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")
Upvotes: 1