Skip to content

Commit 03ee5fb

Browse files
Merge pull request #288 from VijayadharshiniMathiyalagan/ES-876653-How-to-expand-and-collapse-content-based-on-headings-in-a-Word-document
Add sample for expand and collapse content based on headings
2 parents fa6d961 + 856506c commit 03ee5fb

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-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.35417.141 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Expand-and-collapse-content", "Expand-and-collapse-content\Expand-and-collapse-content.csproj", "{41C50C4B-1938-4E75-BA24-0F20AE83A05E}"
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+
{41C50C4B-1938-4E75-BA24-0F20AE83A05E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{41C50C4B-1938-4E75-BA24-0F20AE83A05E}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{41C50C4B-1938-4E75-BA24-0F20AE83A05E}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{41C50C4B-1938-4E75-BA24-0F20AE83A05E}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Expand_and_collapse_content</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="Output\.gitkeep">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using Syncfusion.DocIO.DLS;
2+
using Syncfusion.DocIO;
3+
4+
// Create a new Word document and add a section to it.
5+
WordDocument document = new WordDocument();
6+
WSection section = document.AddSection() as WSection;
7+
8+
// Add a paragraph and append text to it.
9+
WParagraph paragraph = section.AddParagraph() as WParagraph;
10+
paragraph.AppendText("The Giant Panda");
11+
// Apply heading level 1.
12+
paragraph.ApplyStyle(BuiltinStyle.Heading1);
13+
// Add a paragraph and append text to it.
14+
paragraph = section.AddParagraph() as WParagraph;
15+
paragraph.AppendText("The giant panda, which only lives in China outside of captivity, has captured the hearts of people of all ages across the globe.");
16+
17+
// Add a paragraph and append text to it.
18+
paragraph = section.AddParagraph() as WParagraph;
19+
paragraph.AppendText("Small panda or Large Raccoon?");
20+
// Apply heading level 2.
21+
paragraph.ApplyStyle(BuiltinStyle.Heading2);
22+
// Add a paragraph and append text to it.
23+
paragraph = section.AddParagraph() as WParagraph;
24+
paragraph.AppendText("Giant pandas are generally referred to as bears and are typically called panda bears rather than giant pandas.it has several characteristics in common with the red panda.");
25+
26+
// Add a paragraph and append text to it.
27+
paragraph = section.AddParagraph() as WParagraph;
28+
paragraph.AppendText("Adventure Works Cycles");
29+
// Apply heading level 1.
30+
paragraph.ApplyStyle(BuiltinStyle.Heading1);
31+
// Add a paragraph and append text to it.
32+
paragraph = section.AddParagraph() as WParagraph;
33+
paragraph.AppendText("Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company.");
34+
35+
// Add a paragraph and append text to it.
36+
paragraph = section.AddParagraph() as WParagraph;
37+
paragraph.AppendText("Product Overview");
38+
// Apply heading level 2.
39+
paragraph.ApplyStyle(BuiltinStyle.Heading2);
40+
// Add a paragraph and append text to it.
41+
paragraph = section.AddParagraph() as WParagraph;
42+
paragraph.AppendText("While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base.");
43+
44+
// Save the document.
45+
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.OpenOrCreate, FileAccess.ReadWrite))
46+
{
47+
document.Save(outputStream, FormatType.Docx);
48+
}

0 commit comments

Comments
 (0)