diff --git a/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list.sln b/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list.sln new file mode 100644 index 000000000..79cec6b72 --- /dev/null +++ b/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36518.9 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cloned-and-add-table-row-with-restart-numbered-list", "Cloned-and-add-table-row-with-restart-numbered-list\Cloned-and-add-table-row-with-restart-numbered-list.csproj", "{78E727C6-B0F8-43EF-91CA-FCBD28CE9A70}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {78E727C6-B0F8-43EF-91CA-FCBD28CE9A70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78E727C6-B0F8-43EF-91CA-FCBD28CE9A70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78E727C6-B0F8-43EF-91CA-FCBD28CE9A70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78E727C6-B0F8-43EF-91CA-FCBD28CE9A70}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1444F73B-CB15-4B82-A264-556FD70226DE} + EndGlobalSection +EndGlobal diff --git a/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list/Cloned-and-add-table-row-with-restart-numbered-list.csproj b/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list/Cloned-and-add-table-row-with-restart-numbered-list.csproj new file mode 100644 index 000000000..e9e9ce6bf --- /dev/null +++ b/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list/Cloned-and-add-table-row-with-restart-numbered-list.csproj @@ -0,0 +1,24 @@ + + + + Exe + net8.0 + Cloned_and_add_table_row_with_restart_numbered_list + enable + enable + + + + + + + + + Always + + + Always + + + + diff --git a/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list/Data/Input.docx b/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list/Data/Input.docx new file mode 100644 index 000000000..93a6ed45d Binary files /dev/null and b/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list/Data/Input.docx differ diff --git a/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list/Output/.gitkeep b/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list/Program.cs b/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list/Program.cs new file mode 100644 index 000000000..06c315506 --- /dev/null +++ b/Tables/Cloned-and-add-table-row-with-restart-numbered-list/.NET/Cloned-and-add-table-row-with-restart-numbered-list/Program.cs @@ -0,0 +1,47 @@ +using Syncfusion.DocIO.DLS; + +namespace Cloned_and_add_table_row_with_restart_numbered_list +{ + class Program + { + public static void Main(string[] args) + { + // Load the existing Word document + WordDocument document = new WordDocument(Path.GetFullPath(@"Data\Input.docx")); + // Retrieve the first table from the last section of the document + WTable table = (WTable)document.LastSection.Tables[0]; + // Clone the third row (index 2) of the table + WTableRow clonedRow = table.Rows[2].Clone(); + // Insert the cloned row back into the table at position 3 (after the original row) + table.Rows.Insert(3, clonedRow); + // Iterate through all cells in the newly inserted row (row index 3) + foreach (WTableCell cell in table.Rows[3].Cells) + { + // Flag to track whether the first list paragraph has been encountered + bool isListStart = false; + // Iterate through all paragraphs inside the current cell + foreach (WParagraph paragraph in cell.Paragraphs) + { + // Check if paragraph is a list + if (paragraph.ListFormat.ListType != ListType.NoList) + { + // If a list has already started, continue numbering to align with the existing list + if (isListStart) + paragraph.ListFormat.ContinueListNumbering(); + else + { + // Mark that the first list paragraph has been found + isListStart = true; + // Restart numbering for the first list paragraph in the cloned ro + paragraph.ListFormat.RestartNumbering = true; + } + } + } + } + // Save the Word document + document.Save(Path.GetFullPath("../../../Output/Output.docx")); + // Close the Word document + document.Close(); + } + } +}