Phần
Contents
[
Hide
]
Ví dụ về việc quản lý các phần của bản trình chiếu — thêm, truy cập, xóa và đổi tên chúng một cách lập trình bằng Aspose.Slides for PHP via Java.
Thêm một phần
Tạo một phần bắt đầu tại một slide cụ thể.
function addSection() {
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
// Chỉ định slide đánh dấu đầu của phần.
$presentation->getSections()->addSection("New Section", $slide);
$presentation->save("section.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
Truy cập một phần
Đọc thông tin phần từ bản trình chiếu.
function accessSection() {
$presentation = new Presentation("section.pptx");
try {
// Truy cập một phần theo chỉ mục.
$section = $presentation->getSections()->get_Item(0);
$sectionName = $section->getName();
} finally {
$presentation->dispose();
}
}
Xóa một phần
Xóa một phần đã được thêm trước đó.
function removeSection() {
$presentation = new Presentation("section.pptx");
try {
$section = $presentation->getSections()->get_Item(0);
// Xóa phần.
$presentation->getSections()->removeSection($section);
$presentation->save("section_removed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}
Đổi tên một phần
Thay đổi tên của một phần hiện có.
function renameSection() {
$presentation = new Presentation("section.pptx");
try {
$section = $presentation->getSections()->get_Item(0);
$section->setName("New Name");
$presentation->save("section_renamed.pptx", SaveFormat::Pptx);
} finally {
$presentation->dispose();
}
}