Skip to content

Commit 3f9aeea

Browse files
Added sample for expand and collapse content based on headings
1 parent 1ffe70f commit 3f9aeea

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 main heading with Heading 1 style.
9+
WParagraph paragraph = section.AddParagraph() as WParagraph;
10+
paragraph.AppendText("The Giant Panda");
11+
paragraph.ApplyStyle(BuiltinStyle.Heading1);
12+
13+
// Add a descriptive paragraph following the main heading.
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. From their furry black and white bodies to their shy and docile nature, they are considered one of the world's most loved animals.");
16+
17+
// Add a subheading under the main section and apply Heading 2 style
18+
paragraph = section.AddParagraph() as WParagraph;
19+
paragraph.AppendText("Opposable Pseudo Thumb");
20+
paragraph.ApplyStyle(BuiltinStyle.Heading2);
21+
22+
// Add a paragraph describing content relevant to the first subheading.
23+
paragraph = section.AddParagraph() as WParagraph;
24+
paragraph.AppendText("A characteristic of the giant panda that has mystified scientists is their movable, elongated wrist bone that acts like an opposable thumb. This human-like quality that helps give them even more of a cuddly-panda appearance enables the giant panda to pick up objects and even eat sitting up.");
25+
26+
// Add another subheading under the main section and apply Heading 2 style.
27+
paragraph = section.AddParagraph() as WParagraph;
28+
paragraph.AppendText("Small panda or Large Raccoon?");
29+
paragraph.ApplyStyle(BuiltinStyle.Heading2);
30+
31+
// Add a paragraph with content relevant to the second subheading.
32+
paragraph = section.AddParagraph() as WParagraph;
33+
paragraph.AppendText("Giant pandas are generally referred to as bears and are typically called panda bears rather than giant pandas.");
34+
35+
// Add a second main heading and apply Heading 1 style.
36+
paragraph = section.AddParagraph() as WParagraph;
37+
paragraph.AppendText("Adventure Works Cycles");
38+
paragraph.ApplyStyle(BuiltinStyle.Heading1);
39+
40+
// Add a paragraph with descriptive content for the second main section.
41+
paragraph = section.AddParagraph() as WParagraph;
42+
paragraph.AppendText("Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company.");
43+
44+
// Save the document.
45+
using (FileStream outputStream1 = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.OpenOrCreate, FileAccess.ReadWrite))
46+
{
47+
document.Save(outputStream1, FormatType.Docx);
48+
}

0 commit comments

Comments
 (0)