-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #249 from VijayadharshiniMathiyalagan/ES-876652-Ho…
…w-to-change-the-font-of-table-content-in-a-Word-document ES-876652 Added change font table content sample
- Loading branch information
Showing
5 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
Tables/Change-font-of-table-content/Change-font-of-table-content.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.12.35309.182 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Change-font-of-table-content", "Change-font-of-table-content\Change-font-of-table-content.csproj", "{5510835E-0856-4A22-ABEC-80957F810A16}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{5510835E-0856-4A22-ABEC-80957F810A16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5510835E-0856-4A22-ABEC-80957F810A16}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5510835E-0856-4A22-ABEC-80957F810A16}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5510835E-0856-4A22-ABEC-80957F810A16}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {4D0250FF-F767-4F12-813F-5ACFC09975A8} | ||
EndGlobalSection | ||
EndGlobal |
24 changes: 24 additions & 0 deletions
24
...ge-font-of-table-content/Change-font-of-table-content/Change-font-of-table-content.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Change_font_of_table_content</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="Data\Input.docx"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Output\.gitkeep"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+75.6 KB
Tables/Change-font-of-table-content/Change-font-of-table-content/Data/Input.docx
Binary file not shown.
1 change: 1 addition & 0 deletions
1
Tables/Change-font-of-table-content/Change-font-of-table-content/Output/.gitkeep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
39 changes: 39 additions & 0 deletions
39
Tables/Change-font-of-table-content/Change-font-of-table-content/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Syncfusion.DocIO.DLS; | ||
using Syncfusion.DocIO; | ||
|
||
using (FileStream inputStream = new FileStream("Data/Input.docx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) | ||
{ | ||
// Open the input Word document. | ||
using (WordDocument document = new WordDocument(inputStream, FormatType.Docx)) | ||
{ | ||
// Find a table by Title. | ||
WTable table = document.FindItemByProperty(EntityType.Table, "Title", "Adventure") as WTable; | ||
// Iterate through each row in the table. | ||
foreach (WTableRow row in table.Rows) | ||
{ | ||
// Iterate through each cell in the row. | ||
foreach (WTableCell cell in row.Cells) | ||
{ | ||
// Iterate through each paragraph in the cell. | ||
foreach (WParagraph paragraph in cell.Paragraphs) | ||
{ | ||
// Iterate through the child entities of the paragraph. | ||
foreach (Entity entity in paragraph.ChildEntities) | ||
{ | ||
// Check if the child entity is a text range. | ||
if (entity is WTextRange) | ||
{ | ||
// Change the font to Algerian for the text range. | ||
(entity as WTextRange).CharacterFormat.FontName = "Algerian"; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
// Save the modified Word document. | ||
using (FileStream outputStream = new FileStream("Output/Output.docx", FileMode.Create, FileAccess.Write)) | ||
{ | ||
document.Save(outputStream, FormatType.Docx); | ||
} | ||
} | ||
} |