原創|使用教程|編輯:王香|2017-08-10 15:22:26.000|閱讀 628 次
概述:Spire.Presentation是一個專業的 PowerPoint控件,用于幫助開發人員高效地創建、讀取、編輯、轉換和打印任PPT文檔,本文介紹了如何在PPT中設置表行高度和列寬度。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
本文演示如何使用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
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn