@mp2,
Regarding WORDSNET-22681, please check the following points and tell what exactly your requirement is:
- Just an example of how one can add a left/right column with a given index. In this case we can suggest the following code:
private void InsertColumnsToTheLeft(Table tbl, int initCellInd)
{
foreach (Row row in tbl.Rows)
{
Cell newCell = new Cell(tbl.Document);
Paragraph para = new Paragraph(tbl.Document);
newCell.ChildNodes.Add(para);
int newCellInd = initCellInd < row.Cells.Count
? initCellInd
: row.Cells.Count - 1;
row.Cells.Insert(newCellInd, newCell);
}
}
private void InsertColumnsToTheRight(Table tbl, int initCellInd)
{
foreach (Row row in tbl.Rows)
{
Cell newCell = new Cell(tbl.Document);
Paragraph para = new Paragraph(tbl.Document);
newCell.ChildNodes.Add(para);
int newCellInd = initCellInd < row.Cells.Count
? initCellInd + 1
: row.Cells.Count;
row.Cells.Insert(newCellInd, newCell);
}
}
-
An example of how to thoroughly simulate MS Word’s behavior when calling “Insert Columns to the Left/Right”
-
Public API of MS Word’s behavior when calling “Insert Columns to the Left/Right”
If you are interested in items 2 and 3, then this will require a significantly longer research and testing of this functionality. This is due to the fact that MS Word’s behavior in this case is not clear, namely, copying of formatting of a cell, paragraph and table style, while there is a dependence on the initially selected cell when calling this command and its position relative to other cells.