Skip to content

Commit fe6c9a4

Browse files
Merge branch 'main' of https://github.com/SyncfusionExamples/DocIO-Examples into ES-876618-Replace-text-in-list-paragraph
2 parents c36bf65 + c34bc82 commit fe6c9a4

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-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.35417.141 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Copy-table-from-another-document", "Copy-table-from-another-document\Copy-table-from-another-document.csproj", "{79C7E267-BE06-4DF4-B19A-80828ACFBC6B}"
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+
{79C7E267-BE06-4DF4-B19A-80828ACFBC6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{79C7E267-BE06-4DF4-B19A-80828ACFBC6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{79C7E267-BE06-4DF4-B19A-80828ACFBC6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{79C7E267-BE06-4DF4-B19A-80828ACFBC6B}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 24 additions & 0 deletions
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>Copy_table_from_another_document</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\Input.docx">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Output\.gitkeep">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
24+
</Project>
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
4+
// Creates a new Word document.
5+
using (WordDocument destinationDocument = new WordDocument())
6+
{
7+
using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
8+
{
9+
// Opens an existing Word document.
10+
using (WordDocument sourceDocument = new WordDocument(inputStream, FormatType.Automatic))
11+
{
12+
// Add new section.
13+
WSection section = destinationDocument.AddSection() as WSection;
14+
// Get the table from source document and clone.
15+
WTable table = sourceDocument.LastSection.Tables[0].Clone() as WTable;
16+
// Insert the cloned table to destination document.
17+
section.Body.ChildEntities.Insert(0, table);
18+
// Saves the destination document.
19+
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
20+
{
21+
destinationDocument.Save(outputStream, FormatType.Docx);
22+
}
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)