PPT控件Spire.Presentation 教程:在PPT中设置表行高度和列宽度

本文演示如何使用C#和VB.NET中的Spire.Presentation在PowerPoint文档中设置现有表的行高和列宽。

以下屏幕截图显示了设置行高和列宽之前的表。

图片1

详细步骤:

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);

截图:

图片2

完整代码:

[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

慧都控件网

转载于:https://my.oschina.net/u/3006003/blog/1505995

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值