ApiExamples.ExTableColumn.InsertNewColumnIntoTable C# (CSharp) Метод

InsertNewColumnIntoTable() приватный Метод

private InsertNewColumnIntoTable ( ) : void
Результат void
        public void InsertNewColumnIntoTable()
        {
            Document doc = new Document(MyDir + "Table.Document.doc");
            Table table = (Table)doc.GetChild(NodeType.Table, 1, true);

            //ExStart
            //ExId:InsertNewColumn
            //ExSummary:Shows how to insert a blank column into a table.
            // Get the second column in the table.
            Column column = Column.FromIndex(table, 1);

            // Create a new column to the left of this column.
            // This is the same as using the "Insert Column Before" command in Microsoft Word.
            Column newColumn = column.InsertColumnBefore();

            // Add some text to each of the column cells.
            foreach (Cell cell in newColumn.Cells)
                cell.FirstParagraph.AppendChild(new Run(doc, "Column Text " + newColumn.IndexOf(cell)));
            //ExEnd

            doc.Save(MyDir + @"\Artifacts\Table.InsertColumn.doc");

            Assert.AreEqual(24, table.GetChildNodes(NodeType.Cell, true).Count);
            Assert.AreEqual("Column Text 0", table.FirstRow.Cells[1].ToString(SaveFormat.Text).Trim());
            Assert.AreEqual("Column Text 3", table.LastRow.Cells[1].ToString(SaveFormat.Text).Trim());
        }