原創(chuàng)|使用教程|編輯:王香|2017-08-10 15:22:26.000|閱讀 641 次
概述:Spire.Presentation是一個(gè)專(zhuān)業(yè)的 PowerPoint控件,用于幫助開(kāi)發(fā)人員高效地創(chuàng)建、讀取、編輯、轉(zhuǎn)換和打印任PPT文檔,本文介紹了如何在PPT中設(shè)置表行高度和列寬度。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
相關(guān)鏈接:
本文演示如何使用C#和VB.NET中的Spire.Presentation在PowerPoint文檔中設(shè)置現(xiàn)有表的行高和列寬。
以下屏幕截圖顯示了設(shè)置行高和列寬之前的表。

詳細(xì)步驟:
Step 1: 實(shí)例化Presentation對(duì)象并加載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:設(shè)置表行高和列寬。
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
					本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn