分節

使用 Aspose.Slides for .NET 以程式方式管理簡報分節——新增、存取、移除與重新命名的範例。

新增分節

建立一個從特定投影片開始的分節。

static void AddSection()
{
    using var presentation = new Presentation();
    var slide = presentation.Slides[0];

    // 指定標示此分節開始的投影片。
    presentation.Sections.AddSection("New Section", slide);
}

存取分節

從簡報中讀取分節資訊。

static void AccessSection()
{
    using var presentation = new Presentation();
    var slide = presentation.Slides[0];

    presentation.Sections.AddSection("My Section", slide);

    // 依索引存取分節。
    var section = presentation.Sections[0];
    var sectionName = section.Name;
}

移除分節

刪除先前新增的分節。

static void RemoveSection()
{
    using var presentation = new Presentation();
    var slide = presentation.Slides[0];

    var section = presentation.Sections.AddSection("Temporary Section", slide);

    // 移除第一個分節。
    presentation.Sections.RemoveSection(section);
}

重新命名分節

變更現有分節的名稱。

static void RenameSection()
{
    using var presentation = new Presentation();
    var slide = presentation.Slides[0];

    presentation.Sections.AddSection("Old Name", slide);

    var section = presentation.Sections[0];
    section.Name = "New Name";
}