Xceed Words for .NET v5.0 Documentation
Welcome to Xceed Words for .NET v5.0 / Code Snippets / Adding rows and columns to an existing table
In This Topic
    Adding rows and columns to an existing table
    In This Topic

    The following example demonstrates how to add rows and columns to an existing Table.

    C#
    Copy Code
        private void TablesAndCells( string file, int tableIndex )
        {
          using( var document = DocX.Load( file ) )
          {
            // Get the table to modify
            var table = document.Tables[ tableIndex ];
    
            // Add a new column at the end
            table.InsertColumn();
    
            // Add a new row at the end
            table.InsertRow();
    
            // Save the changes to the document
            document.Save();
          }
        }

     

    The InsertRow and InsertColumn methods have a few overloads, see their documentation for more details