您的位置:首页 > 其它

PPT控件Spire.Presentation 教程:在PPT中设置表行高度和列宽度

2017-08-10 00:00 281 查看
摘要: Spire.Presentation是一个专业的 PowerPoint控件,用于帮助开发人员高效地创建、读取、编辑、转换和打印任PPT文档,本文介绍了如何在PPT中设置表行高度和列宽度。

本文演示如何使用C#和VB.NET中的Spire.Presentation在PowerPoint文档中设置现有表的行高和列宽。

以下屏幕截图显示了设置行高和列宽之前的表。



详细步骤:

Step 1: 实例化Presentation对象并加载PowerPoint文档。

Presentation ppt = new Presentation();
ppt.LoadFromFile("Input.pptx");

Step 2: 获得第一张幻灯片。

ISlide slide = ppt.Slides[0];

Step 3:获取幻灯片上的第一张表。

ITable table = ppt.Slides[0].Shapes[0] as ITable;

Step 4:设置表行高和列宽。

table.TableRows[1].Height = 50;
table.ColumnsList[1].Width = 100;

Step 5:保存文档。

ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013);

截图:



完整代码:

[C#]

using Spire.Presentation;
namespace Set_table_column_width_and_row_height
{
class Program
{
static void Main(string[] args)
{
Presentation ppt = new Presentation(); ppt.LoadFromFile("Input.pptx");
ISlide slide = ppt.Slides[0];
ITable table = ppt.Slides[0].Shapes[0] as ITable;
table.TableRows[1].Height = 50; table.ColumnsList[1].Width = 100;
ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013);
}
}
}End Namespace

[VB.NET]

Imports Spire.Presentation
Namespace Set_table_column_width_and_row_height
Class Program
Private Shared Sub Main(args As String())
Dim ppt As New Presentation()
ppt.LoadFromFile("Input.pptx")
Dim slide As ISlide = ppt.Slides(0)
Dim table As ITable = TryCast(ppt.Slides(0).Shapes(0), ITable)
table.TableRows(1).Height = 50
table.ColumnsList(1).Width = 100
ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013)
End Sub
End Class

慧都控件网
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息