Sections

Presentation.Sections 属性

返回演示文稿中定义的所有幻灯片部分的列表。只读 ISectionCollection

public ISectionCollection Sections { get; }

示例

以下示例演示如何在 PowerPoint 演示文稿中创建部分。

[C#]
using (Presentation pres = new Presentation())
{
    ISlide defaultSlide = pres.Slides[0];
    ISlide newSlide1 = pres.Slides.AddEmptySlide(pres.LayoutSlides[0]);
    ISlide newSlide2 = pres.Slides.AddEmptySlide(pres.LayoutSlides[0]);
    ISlide newSlide3 = pres.Slides.AddEmptySlide(pres.LayoutSlides[0]);
    ISlide newSlide4 = pres.Slides.AddEmptySlide(pres.LayoutSlides[0]);
    ISection section1 = pres.Sections.AddSection("Section 1", newSlide1);
	// section1 将在 newSlide2 结束,之后将开始 section2
    ISection section2 = pres.Sections.AddSection("Section 2", newSlide3);
    pres.Save("pres-sections.pptx", SaveFormat.Pptx);
    pres.Sections.ReorderSectionWithSlides(section2, 0);
    pres.Save("pres-sections-moved.pptx", SaveFormat.Pptx);
    pres.Sections.RemoveSectionWithSlides(section2);
    pres.Sections.AppendEmptySection("Last empty section");
    pres.Save("pres-section-with-empty.pptx",SaveFormat.Pptx);
}

以下示例演示如何更改部分的名称。

[C#]
using (Presentation pres = new Presentation("pres.pptx"))
{
   ISection section = pres.Sections[0];
   section.Name = "My section";
}

另请参阅