-
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 #263 from Suriya-Balamurugan/ES-894932-Get-heading…
…-list-value Added sample to retrieve list values for a specific heading in a Word document
- 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
Paragraphs/Get-heading-list-value/.NET/Get-heading-list-value.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 16 | ||
VisualStudioVersion = 16.0.31911.196 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Get-heading-list-value", "Get-heading-list-value\Get-heading-list-value.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4} | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+20.8 KB
Paragraphs/Get-heading-list-value/.NET/Get-heading-list-value/Data/Template.docx
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
Paragraphs/Get-heading-list-value/.NET/Get-heading-list-value/Get-heading-list-value.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,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Get_heading_list_value</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="Data\Template.docx"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Output\.gitkeep"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
1 change: 1 addition & 0 deletions
1
Paragraphs/Get-heading-list-value/.NET/Get-heading-list-value/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 @@ | ||
|
41 changes: 41 additions & 0 deletions
41
Paragraphs/Get-heading-list-value/.NET/Get-heading-list-value/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,41 @@ | ||
using Syncfusion.DocIO; | ||
using Syncfusion.DocIO.DLS; | ||
using System.Collections.Generic; | ||
using System; | ||
using System.IO; | ||
|
||
namespace Get_heading_list_value | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) | ||
{ | ||
//Open an existing Word document from the file stream. | ||
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx)) | ||
{ | ||
//Get the document text. | ||
document.GetText(); | ||
//Find all paragraphs with the style 'Heading 3' in the Word document. | ||
List<Entity> headingParagraphs = document.FindAllItemsByProperty(EntityType.Paragraph, "StyleName", "Heading 3"); | ||
if (headingParagraphs.Count == 0) | ||
Console.WriteLine("No paragraphs with the style 'Heading 3' found."); | ||
else | ||
{ | ||
foreach (Entity paragraph in headingParagraphs) | ||
{ | ||
//Get the string that represents the appearance of list value of the paragraph. | ||
if (paragraph is WParagraph) | ||
Console.WriteLine((paragraph as WParagraph).ListString); | ||
else | ||
Console.WriteLine("The entity is not a WParagraph."); | ||
} | ||
} | ||
//Pauses the console to display the output. | ||
Console.ReadLine(); | ||
} | ||
} | ||
} | ||
} | ||
} |