Skip to content

Commit 592e385

Browse files
Merge pull request #325 from SyncfusionExamples/889575-Add-checkbox-using-IF-field
889575-Add sample Add-checkbox-using-IF-field
2 parents 4da7140 + 91a8b05 commit 592e385

File tree

6 files changed

+81
-0
lines changed

6 files changed

+81
-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}") = "Add-checkbox-using-IF-field", "Add-checkbox-using-IF-field\Add-checkbox-using-IF-field.csproj", "{CA5A6732-5DE0-435E-8C4B-A71CC38D5D1B}"
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+
{CA5A6732-5DE0-435E-8C4B-A71CC38D5D1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{CA5A6732-5DE0-435E-8C4B-A71CC38D5D1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{CA5A6732-5DE0-435E-8C4B-A71CC38D5D1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{CA5A6732-5DE0-435E-8C4B-A71CC38D5D1B}.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>Add_checkbox_using_IF_field</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>
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Binary file not shown.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
4+
namespace Add_checkbox_using_IF_field
5+
{
6+
internal class Program
7+
{
8+
static void Main(string[] args)
9+
{
10+
//Opens the template document
11+
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
12+
{
13+
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Automatic))
14+
{
15+
//Merge field names and values
16+
string[] fieldName = { "Name", "Email", "Option1","Option2" };
17+
string[] fieldValue = { "John", "[email protected]", "YES","NO" };
18+
//Execute mail merge
19+
document.MailMerge.Execute(fieldName, fieldValue);
20+
//Update fields
21+
document.UpdateDocumentFields();
22+
23+
//Creates file stream.
24+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
25+
{
26+
//Saves the Word document to file stream.
27+
document.Save(outputFileStream, FormatType.Docx);
28+
}
29+
30+
}
31+
}
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)