PPT控制元件Spire.Presentation 教程:在PPT中設定錶行高度和列寬度
阿新 • • 發佈:2019-02-05
本文演示如何使用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