We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Edit cell's text

is there a way to edit the cell's test in a row?

want i am trying to do is open the attached doc and duplicate the existing rows for each row in a database table and remove the current cells text and insert new text using the cell's text as a pointer to a field in the table's row.

i chose this method becasue the the "prototype" word table can have multiple rows with differing number of cells.

Thanks,

i came up with this. i don;t know of a better way

Dim doc As New Aspose.Words.Document("C:\a\a.doc")

Dim ns As Aspose.Words.NodeCollection = doc.GetChildNodes(Aspose.Words.NodeType.Table, True)

For Each n As Aspose.Words.Tables.Table In ns

Dim rc As New List(Of Aspose.Words.Tables.Row)

Dim rc2 As New List(Of Aspose.Words.Tables.Row)

For i As Integer = 1 To n.Rows.Count - 1

Dim r As Aspose.Words.Tables.Row = n.Rows(i)

rc.Add(CType(r.Clone(True), Aspose.Words.Tables.Row))

rc2.Add(r)

Next

'Next

For i As Integer = 0 To 2

For Each rr As Aspose.Words.Tables.Row In rc

Dim newRow As Aspose.Words.Tables.Row = CType(rr.Clone(False), Aspose.Words.Tables.Row)

For Each c As Aspose.Words.Tables.Cell In rr

Dim newCell As Aspose.Words.Tables.Cell = CType(c.Clone(False), Aspose.Words.Tables.Cell)

Dim para As New Aspose.Words.Paragraph(doc)

newCell.AppendChild(para)

newRow.AppendChild(newCell)

Dim b As New Aspose.Words.DocumentBuilder(doc)

b.MoveTo(para)

b.Write("")

Next

n.Rows.Add(newRow)

Next

Next

For Each r As Aspose.Words.Tables.Row In rc2

n.Rows.Remove(r)

Next

Next

doc.Save("C:\a\a1.doc")

Hi Tom,

Thanks for your inquiry.

I think using mail merge would be easier to achieve what you are looking for. Please take a look at the mail merge section of the documentation here. Specifically using mail merge with regions will allow you to automatically grow rows of a table as you populate it with data.

Thanks,