Skip to content

Commit

Permalink
Merge pull request #263 from Suriya-Balamurugan/ES-894932-Get-heading…
Browse files Browse the repository at this point in the history
…-list-value

Added sample to retrieve list values for a specific heading in a Word document
  • Loading branch information
MohanaselvamJothi authored Oct 22, 2024
2 parents bee1308 + cde0f17 commit ac7e8c4
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Paragraphs/Get-heading-list-value/.NET/Get-heading-list-value.sln
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 not shown.
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

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();
}
}
}
}
}

0 comments on commit ac7e8c4

Please sign in to comment.