Aspose.Words.Examples.CSharp.Programming_Documents.Working_with_Tables.CloneTable.CloneCompleteTable C# (CSharp) Method

CloneCompleteTable() private static method

Shows how to clone complete table.
private static CloneCompleteTable ( string dataDir ) : void
dataDir string
return void
        private static void CloneCompleteTable(string dataDir)
        {
            // ExStart:CloneCompleteTable
            Document doc = new Document(dataDir + "Table.SimpleTable.doc");

            // Retrieve the first table in the document.
            Table table = (Table)doc.GetChild(NodeType.Table, 0, true);

            // Create a clone of the table.
            Table tableClone = (Table)table.Clone(true);

            // Insert the cloned table into the document after the original
            table.ParentNode.InsertAfter(tableClone, table);

            // Insert an empty paragraph between the two tables or else they will be combined into one
            // Upon save. This has to do with document validation.
            table.ParentNode.InsertAfter(new Paragraph(doc), table);
            dataDir = dataDir + "Table.CloneTableAndInsert_out.doc";
           
            // Save the document to disk.
            doc.Save(dataDir);
            // ExEnd:CloneCompleteTable
            Console.WriteLine("\nTable cloned successfully.\nFile saved at " + dataDir);
        }
        /// <summary>