Hi
Thanks for your request. There is no “column” concept in the Word table. By Microsoft Word design rows in a table in a Microsoft Word document are completely independent. It means each row can have any number of cells of any width.
Please see the following code example which demonstrates how to remove table column:
// Open source document
Document doc = new Document("in.doc");
// Get BookMark node
Node bmNode = doc.Range.Bookmarks["RemoveThisColumn"].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");
Bookmark “RemoveThisColumn” is located in first Cell of the “column”.