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
输出: