Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Cloned_and_add_table_row_with_restart_numbered_list</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\Input.docx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Loading