gpt4 book ai didi

c# - 如何在 C# 或 Perl 中以编程方式打开 PowerPoint 演示文稿并将其另存为 HTML/JPEG?

转载 作者:太空狗 更新时间:2023-10-29 18:01:50 29 4
gpt4 key购买 nike

我正在寻找能做到这一点的代码片段,最好是用 C# 甚至 Perl。

我希望这不是一项艰巨的任务;)

最佳答案

以下将打开 C:\presentation1.ppt 并将幻灯片保存为 C:\Presentation1\slide1.jpg

如果您需要获取互操作程序集,可以在 Office 安装程序的“工具”下找到它,或者您可以从 here (office 2003) 下载它。 .如果您有更新版本的 office,您应该能够从那里找到其他版本的链接。

using Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;

namespace PPInterop
{
class Program
{
static void Main(string[] args)
{
var app = new PowerPoint.Application();

var pres = app.Presentations;

var file = pres.Open(@"C:\Presentation1.ppt", MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);

file.SaveCopyAs(@"C:\presentation1.jpg", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsJPG, MsoTriState.msoTrue);
}
}
}

编辑: Sinan's version使用导出看起来是更好的选择,因为您可以指定输出分辨率。对于 C#,将上面的最后一行更改为:

file.Export(@"C:\presentation1.jpg", "JPG", 1024, 768);

关于c# - 如何在 C# 或 Perl 中以编程方式打开 PowerPoint 演示文稿并将其另存为 HTML/JPEG?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1038019/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com