本文演示如何使用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