本文将介绍如何使用Spire.Presentation for Java设置和获取PowerPoint幻灯片的标题。
设置幻灯片标题
import com.spire.presentation.FileFormat;
import com.spire.presentation.ISlide;
import com.spire.presentation.Presentation;
public class SetSlideTitle {
public static void main(String[] args) throws Exception {
//创建Presentation实例
Presentation ppt = new Presentation();
//获取第一张幻灯片
ISlide slide = ppt.getSlides().get(0);
//给幻灯片设置标题
slide.setTitle("幻灯片标题");
//保存文档
ppt.saveToFile("SetTitle.pptx", FileFormat.PPTX_2013);
}
}
获取幻灯片标题
import com.spire.presentation.ISlide;
import com.spire.presentation.Presentation;
public class GetSlideTitle {
public static void main(String[] args) throws Exception {
//创建Presentation实例
Presentation ppt = new Presentation();
//加载PowerPoint文档
ppt.loadFromFile("SetTitle.pptx");
//获取第一张幻灯片
ISlide slide = ppt.getSlides().get(0);
//打印幻灯片标题
String tile = slide.getTitle();
System.out.println(tile);
}
}