Skip to content

Commit 4459a30

Browse files
Merge pull request #302 from SureshGanesanSF4645/main
Update GitHub for FT sample
2 parents 4485df6 + 7a68381 commit 4459a30

File tree

36 files changed

+184
-77
lines changed

36 files changed

+184
-77
lines changed

Bookmarks/Add-bookmark-in-Word-document/.NET/Add-bookmark-in-Word-document/Program.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ static void Main(string[] args)
1111
//Creates a new Word document.
1212
using (WordDocument document = new WordDocument())
1313
{
14-
//Adds a new section into the Word Document.
15-
IWSection section = document.AddSection();
16-
//Adds a new paragraph into Word document and appends text into paragraph.
17-
IWParagraph paragraph = section.AddParagraph();
18-
paragraph.AppendText("Northwind Database");
19-
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
20-
//Adds a paragraph into section.
21-
paragraph = section.AddParagraph();
14+
//Add a new section and paragraph in the document.
15+
document.EnsureMinimal();
16+
//Get the last paragraph.
17+
IWParagraph paragraph = document.LastParagraph;
2218
//Adds a new bookmark start into paragraph with name "Northwind".
2319
paragraph.AppendBookmarkStart("Northwind");
2420
//Adds a text between the bookmark start and end into paragraph.
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.11.35327.3
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fill-simple-form", "Fill-simple-form\Fill-simple-form.csproj", "{BD83DEC5-BB86-4647-8562-513E15DF50BD}"
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+
{BD83DEC5-BB86-4647-8562-513E15DF50BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{BD83DEC5-BB86-4647-8562-513E15DF50BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{BD83DEC5-BB86-4647-8562-513E15DF50BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{BD83DEC5-BB86-4647-8562-513E15DF50BD}.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 = {986E28DE-AA32-41F5-A66C-CBF891692255}
24+
EndGlobalSection
25+
EndGlobal
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Fill_simple_form_Word_doocument</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+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Binary file not shown.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using System.IO;
4+
5+
//Open the file as stream.
6+
using (FileStream inputDocumentStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
7+
{
8+
//Create a new Word document.
9+
using (WordDocument document = new WordDocument(inputDocumentStream, FormatType.Docx))
10+
{
11+
//Find drop-down content control by title.
12+
InlineContentControl inlineContentControl = document.FindItemByProperty(EntityType.InlineContentControl, "ContentControlProperties.Title", "Status") as InlineContentControl;
13+
WTextRange textRange = inlineContentControl.ParagraphItems[0] as WTextRange;
14+
//Select drop-down
15+
textRange.Text = inlineContentControl.ContentControlProperties.ContentControlListItems[1].DisplayText;
16+
17+
//Find date content control by tag.
18+
inlineContentControl = document.FindItemByProperty(EntityType.InlineContentControl, "ContentControlProperties.Tag", "Date") as InlineContentControl;
19+
textRange = inlineContentControl.ParagraphItems[0] as WTextRange;
20+
//Set today's date to display.
21+
textRange.Text = DateTime.Now.ToShortDateString();
22+
23+
//Find text content control by title.
24+
inlineContentControl = document.FindItemByProperty(EntityType.InlineContentControl, "ContentControlProperties.Title", "ProjectName") as InlineContentControl;
25+
//Fill text.
26+
textRange = inlineContentControl.ParagraphItems[0] as WTextRange;
27+
textRange.Text = "Website for Adventure works cycle";
28+
29+
//Find checkbox content control by type.
30+
inlineContentControl = document.FindItemByProperty(EntityType.InlineContentControl, "ContentControlProperties.Type", "CheckBox") as InlineContentControl;
31+
//Check the checkbox
32+
inlineContentControl.ContentControlProperties.IsChecked = true;
33+
34+
//Create file stream.
35+
using (FileStream outputDocumentStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite))
36+
{
37+
//Save the Word document to file stream.
38+
document.Save(outputDocumentStream, FormatType.Docx);
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)