Skip to content

Commit f0d4fe8

Browse files
ES-879193- Added sample
1 parent a840ca5 commit f0d4fe8

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35309.182
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Find-table-and-add-row", "Find-table-and-add-row\Find-table-and-add-row.csproj", "{E8C23293-ABC9-4C54-81BA-9C5FBA6D85C1}"
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+
{E8C23293-ABC9-4C54-81BA-9C5FBA6D85C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E8C23293-ABC9-4C54-81BA-9C5FBA6D85C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E8C23293-ABC9-4C54-81BA-9C5FBA6D85C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E8C23293-ABC9-4C54-81BA-9C5FBA6D85C1}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {EC6BCFD8-E759-47DE-BC97-AC492B3D6DF8}
24+
EndGlobalSection
25+
EndGlobal
Binary file not shown.
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>Find_table_and_add_row</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>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
4+
5+
//Register Syncfusion license
6+
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Mgo+DSMBMAY9C3t2UlhhQlNHfV5DQmBWfFN0QXNYfVRwdF9GYEwgOX1dQl9nSXZTc0VlWndfcXNSQWc=");
7+
8+
using (FileStream inputFileStream = new FileStream(Path.GetFullPath("Data/Template.docx"), FileMode.Open, FileAccess.ReadWrite))
9+
{
10+
// Open the input Word document
11+
using (WordDocument document = new WordDocument(inputFileStream, FormatType.Docx))
12+
{
13+
// Find a table with its alternate text (Title property).
14+
WTable table = document.FindItemByProperty(EntityType.Table, "Title", "DataTable") as WTable;
15+
// Check if the table exists.
16+
if (table != null)
17+
{
18+
// Add a new row to the table.
19+
table.AddRow();
20+
}
21+
22+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath("Output/Result.docx"), FileMode.Create, FileAccess.Write))
23+
{
24+
// Save the modified document to the output file stream.
25+
document.Save(outputFileStream, FormatType.Docx);
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)