Aspose.Words.Examples.CSharp.Programming_Documents.Working_With_Document.AddRemoveColumn.InsertBlankColumn C# (CSharp) Method

InsertBlankColumn() private static method

private static InsertBlankColumn ( Document doc ) : void
doc Document
return void
        private static void InsertBlankColumn(Document doc)
        {
            // ExStart:InsertBlankColumn
            // Get the first table in the document.
            Table table = (Table)doc.GetChild(NodeType.Table, 0, true);

            // ExStart:GetPlainText
            // Get the second column in the table.
            Column column = Column.FromIndex(table, 0);
            // Print the plain text of the column to the screen.
            Console.WriteLine(column.ToTxt());
            // ExEnd:GetPlainText
            // 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:InsertBlankColumn
            Console.WriteLine("\nColumn added successfully." );  
        }
        // ExStart:ColumnClass