Section

Examples for managing presentation sections—add, access, remove, and rename them programmatically using Aspose.Slides for Android via Java.

Add a Section

Create a section that starts at a specific slide.

static void addSection() {
    Presentation presentation = new Presentation();
    try {
        ISlide slide = presentation.getSlides().get_Item(0);

        // Specify the slide that marks the beginning of the section.
        presentation.getSections().addSection("New Section", slide);
    } finally {
        presentation.dispose();
    }
}

Access a Section

Read section information from a presentation.

static void accessSection() {
    Presentation presentation = new Presentation();
    try {
        ISlide slide = presentation.getSlides().get_Item(0);

        presentation.getSections().addSection("My Section", slide);

        // Access a section by index.
        ISection section = presentation.getSections().get_Item(0);
        String sectionName = section.getName();
    } finally {
        presentation.dispose();
    }
}

Remove a Section

Delete a previously added section.

static void removeSection() {
    Presentation presentation = new Presentation();
    try {
        ISlide slide = presentation.getSlides().get_Item(0);

        ISection section = presentation.getSections().addSection("Temporary Section", slide);

        // Remove the first section.
        presentation.getSections().removeSection(section);
    } finally {
        presentation.dispose();
    }
}

Rename a Section

Change the name of an existing section.

static void renameSection() {
    Presentation presentation = new Presentation();
    try {
        ISlide slide = presentation.getSlides().get_Item(0);

        presentation.getSections().addSection("Old Name", slide);

        ISection section = presentation.getSections().get_Item(0);
        section.setName("New Name");
    } finally {
        presentation.dispose();
    }
}