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

Free Support Forum - aspose.com

Clone Method Gives Unpredictable Results

This is a strange one. I am using code to add rows to a table. The table begins looking like this:

«tablestart:mytable»«Col1» «Col2» «Col3»«tableend:mytable»

Then I run this code:

For x = 1 to 5

It adds the rows, but then I want to run the ExecuteWithRegions method:


On that line of code I get the error “Found end of mail merge region ‘mytable’ without matching start.” When I look at the document it now looks like this:

«Col1» «Col2» «Col3»«tableend:mytable»
«Col1» «Col2» «Col3»«tableend:mytable»
«Col1» «Col2» «Col3»«tableend:mytable»
«Col1» «Col2» «Col3»«tableend:mytable»
«Col1» «Col2» «Col3»«tableend:mytable»
«Col1» «Col2» «Col3»«tableend:mytable»

The ExecuteWithRegions line of code errors out, so it did not run, because the lastrow.clone method used to add rows creates this table. How do I just add rows that are blank, not having the merge fields in them?

Thanks for your request. Try to use the following code to solve this problem.

'Clone last row
Dim row As Row = CType(Table1.LastRow.Clone(True), Row)
'remove all childs of cells in the row
Dim cell As Cell = Nothing
For Each cell In row.Cells
Dim node As Node = Nothing
For Each node In cell.ChildNodes
'add rows into the table
Dim i As Integer
For i = 0 To 5

Best regards.