ส่วน
Contents
[
Hide
]
ตัวอย่างการจัดการส่วนของงานนำเสนอ—เพิ่ม, เข้าถึง, ลบ และเปลี่ยนชื่อโดยใช้ Aspose.Slides for Python via .NET อย่างโปรแกรมเมติก
เพิ่มส่วน
สร้างส่วนที่เริ่มต้นที่สไลด์เฉพาะ
def add_section():
with slides.Presentation() as presentation:
slide = presentation.slides[0]
# เพิ่มส่วนใหม่และระบุสไลด์ที่เป็นจุดเริ่มต้นของส่วน
presentation.sections.add_section("New Section", slide)
presentation.save("section.pptx", slides.export.SaveFormat.PPTX)
เข้าถึงส่วน
รับส่วนจากงานนำเสนอ
def access_section():
with slides.Presentation("section.pptx") as presentation:
# เข้าถึงส่วนโดยใช้ดัชนี.
section = presentation.sections[0]
ลบส่วน
ลบส่วนที่เพิ่มไว้ก่อนหน้านี้
def remove_section():
with slides.Presentation("section.pptx") as presentation:
section = presentation.sections[0]
# ลบส่วน.
presentation.sections.remove_section(section)
presentation.save("section_removed.pptx", slides.export.SaveFormat.PPTX)
เปลี่ยนชื่อส่วน
เปลี่ยนชื่อของส่วนที่มีอยู่
def rename_section():
with slides.Presentation("section.pptx") as presentation:
section = presentation.sections[0]
# เปลี่ยนชื่อส่วน.
section.name = "New Name"
presentation.save("section_renamed.pptx", slides.export.SaveFormat.PPTX)