hi
How to use the delete bookMark way to delete a table column
thanks!
Hi
Thanks for your request. Please see the following code example:
// Open source document
Document doc = new Document("in.doc");
// Get BookMark node
Node bmNode = doc.Range.Bookmarks["TestBookmark"].BookmarkStart;
if (((Paragraph) bmNode.ParentNode).ParentNode.NodeType == NodeType.Cell)
{
// Get cell with bookmark
Cell cell = (Cell)(((Paragraph) bmNode.ParentNode).ParentNode);
// Get index of cell
int cellIndex = cell.ParentRow.IndexOf(cell);
// Remove all cells with cellIndex
foreach(Row row in cell.ParentRow.ParentTable)
{
row.Cells[cellIndex].Remove();
}
}
doc.Save("out.doc");
The bookmark “TestBookmark” is located in first Cell of the “column”.
1 | 2 | 3 | 4 | 5 Bookmark is here | 6 | 7 |
---|---|---|---|---|---|---|
Best regards,
thanks!
How to delete the selected content?
Hi
Thanks for your request. For removing, you should just find the node and call Remove method. Please note, each node has Remove method.
https://reference.aspose.com/words/net/aspose.words/node/remove/
Also please follow the link to learn how to programmatically find a particular word or a phrase in a document using Aspose.Words:
https://docs.aspose.com/words/net/find-and-replace/
Best regards,
hi
How to set the table cell background color?I used the following method, the background color is set successfully, but there will be no value MergeField!
builder.MoveToMergeField("name");
builder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.ColorTranslator.FromHtml("#FFFF00");
thanks!
Dear Kin,
Thank you for your question.
It happens because the method MoveToMergeField(“name”) moves the cursor to a position just beyond the specified merge field and removes the merge field. To leave the merge field just use the overloaded method MoveToMergeField(fieldName, isAfter, isDeleteField).
Hope this helps.