本文演示如何使用C#和VB.NET中的Spire.Presentation在PowerPoint文档中设置现有表的行高和列宽。html
如下屏幕截图显示了设置行高和列宽以前的表。ide
详细步骤:spa
Step 1: 实例化Presentation对象并加载PowerPoint文档。orm
Presentation ppt = new Presentation(); ppt.LoadFromFile("Input.pptx");
Step 2: 得到第一张幻灯片。htm
ISlide slide = ppt.Slides[0];
Step 3:获取幻灯片上的第一张表。对象
ITable table = ppt.Slides[0].Shapes[0] as ITable;
Step 4:设置表行高和列宽。blog
table.TableRows[1].Height = 50; table.ColumnsList[1].Width = 100;
Step 5:保存文档。图片
ppt.SaveToFile("Output.pptx", FileFormat.Pptx2013);
截图:文档
完整代码:get
[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