本文将介绍使用spire.presentation for .net给powerpoint文档添加节的三种方式:
- 添加节到文档末尾
- 插入节到指定位置
- 添加节到指定幻灯片前
添加节到文档末尾
c#
//加载powerpoint文档
presentation ppt = new presentation();
ppt.loadfromfile("input.pptx");
//添加节到文档末尾
section section = ppt.sectionlist.append("new section");
//保存结果文档
ppt.savetofile("addsection.pptx", fileformat.pptx2013);
vb.net
dim ppt as presentation = new presentation()
ppt.loadfromfile("input.pptx")
dim section as section = ppt.sectionlist.append("new section")
ppt.savetofile("addsection.pptx", fileformat.pptx2013)
插入节到指定位置
c#
//加载powerpoint文档
presentation ppt = new presentation();
ppt.loadfromfile("input.pptx");
//插入节到第一个索引位置
section section = ppt.sectionlist.insert(0, "new section");
//保存结果文档
ppt.savetofile("insertsectionatspecifiedposition.pptx", fileformat.pptx2013);
vb.net
dim ppt as presentation = new presentation()
ppt.loadfromfile("input.pptx")
dim section as section = ppt.sectionlist.insert(0, "new section")
ppt.savetofile("insertsectionatspecifiedposition.pptx", fileformat.pptx2013)
添加节到指定幻灯片前
c#
//加载powerpoint文档
presentation ppt = new presentation();
ppt.loadfromfile("input.pptx");
//添加节到第二张幻灯片前面
section section = ppt.sectionlist.add("new section", ppt.slides[1]);
//保存结果文档
ppt.savetofile("addsectionbeforeslide.pptx", fileformat.pptx2013);
vb.net
dim ppt as presentation = new presentation()
ppt.loadfromfile("input.pptx")
dim section as section = ppt.sectionlist.add("new section", ppt.slides(1))
ppt.savetofile("addsectionbeforeslide.pptx", fileformat.pptx2013)