Skip to content

Commit ee60f9e

Browse files
Added the sample Insert-row-to-another-table-with-formatting
1 parent 03bc400 commit ee60f9e

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35527.113 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Insert-row-to-another-table-with-formatting", "Insert-row-to-another-table-with-formatting\Insert-row-to-another-table-with-formatting.csproj", "{5B0540C8-1A4D-4BB4-A0B9-10028D140E00}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{5B0540C8-1A4D-4BB4-A0B9-10028D140E00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{5B0540C8-1A4D-4BB4-A0B9-10028D140E00}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{5B0540C8-1A4D-4BB4-A0B9-10028D140E00}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{5B0540C8-1A4D-4BB4-A0B9-10028D140E00}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Insert_row_to_another_table_with_formatting</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Data\Template.docx">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Output\.gitkeep">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
24+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
4+
// Load the Word document from the specified path.
5+
using (WordDocument document = new WordDocument(Path.GetFullPath(@"Data/Template.docx")))
6+
{
7+
// Access the first table in the last section of the document (source table).
8+
WTable sourceTable = (WTable)document.LastSection.Tables[0];
9+
10+
// Access the second table in the last section of the document (target table).
11+
WTable targetTable = (WTable)document.LastSection.Tables[1];
12+
13+
// Clone the first row from the source table and add it to the target table as first row.
14+
targetTable.Rows.Insert(0, sourceTable.Rows[0].Clone());
15+
16+
// Save the modified document to the specified output path in DOCX format.
17+
document.Save(Path.GetFullPath(@"Output/Result.docx"), FormatType.Docx);
18+
}

0 commit comments

Comments
 (0)