I am using a bookmark to find a specific table/table row, which I then clone one or more times to fill with data and then add to the parent table. I want to remove the bookmarks from the newly added rows, but keep the bookmark on the original row that was cloned. After inserting the new row into the table, I am attempting to clear the bookmarks. However, when I clone, fill, and add a new row again, an error is thrown that says that it can’t find the bookmark. When I inspect the properties of the second new row during debug, the range does contain the bookmark that it claims it can’t find, though I am not actually trying to call the bookmark by name. How can I clear this bookmark from all newly added cells?
Bookmark bkmrk = doc.Range.Bookmarks["tablebookmark"];
Node node = bkmrk.BookmarkStart.ParentNode;
Cell cell = (Cell)node.ParentNode;
Row rowOrig = (Row)cell.ParentRow;
List<TesTDaTa> dat = TestCollection.LoadCollection();
foreach (TesTDaTa t in dat)
{
Row tRow = (Row)rowOrig.Clone(true);
foreach (Cell c in tRow.Cells)
{
string fldName = FindFieldNameFromText(c.Range.Text);
var props = (from p in t.GetType().GetProperties() where p.Name == fldName select p);
if (props.Count() > 0)
{
c.Range.Replace(fldName, t.GetType().GetProperty(fldName).GetValue(t, null).ToString(), false, false);
}
}
rowOrig.ParentTable.AppendChild(tRow);
if (tRow.Range.Bookmarks.Count > 0)
{
tRow.Range.Bookmarks.Clear();
}
}
This message was posted using Aspose.Live 2 Forum