spire.presentation支持给powerpoint表格设置对齐方式,本文将介绍如何将一个powerpoint表格对齐到幻灯片的底部。
原始表格:
c#
using spire.presentation;
namespace aligntableinppt
{
class program
{
static void main(string[] args)
{
//加载powerpoint文档
presentation ppt = new presentation();
ppt.loadfromfile("table.pptx");
itable table = null;
//遍历第一张幻灯片上的所有形状
foreach (ishape shape in ppt.slides[0].shapes)
{
//找到表格并将它对齐到该幻灯片的底部
if (shape is itable)
{
table = (itable)shape;
table.setshapealignment(spire.presentation.shapealignment.alignbottom);
}
}
//保存结果文档
ppt.savetofile("result.pptx", fileformat.pptx2013);
}
}
}
vb.net
imports spire.presentation
namespace aligntableinppt
class program
private shared sub main(args as string())
'加载powerpoint文档
dim ppt as new presentation()
ppt.loadfromfile("table.pptx")
dim table as itable = nothing
'遍历第一张幻灯片上的所有形状
for each shape as ishape in ppt.slides(0).shapes
'找到表格并将它对齐到该幻灯片的底部
if typeof shape is itable then
table = directcast(shape, itable)
table.setshapealignment(spire.presentation.shapealignment.alignbottom)
end if
next
'保存结果文档
ppt.savetofile("result.pptx", fileformat.pptx2013)
end sub
end class
end namespace
输出: