本文将介绍如何使用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);
}
}