使用C#显示powerpoint
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/217890/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using C# to display powerpoint
提问by Berg
Is there any good way to use a windows application written in C# to display/control a powerpoint slideshow? Ultimately I would like to show thumbnails in a form and clicking these thumbnails would advance the slides shown on a second monitor (similar to using Powerpoint itself to show a slideshow on a second monitor).
有没有什么好方法可以使用用 C# 编写的 Windows 应用程序来显示/控制幻灯片放映?最终,我想在表单中显示缩略图,单击这些缩略图将在第二台显示器上显示幻灯片(类似于使用 Powerpoint 本身在第二台显示器上显示幻灯片)。
I would like to be able to use Powerpoint Viewer if Powerpoint is not installed.
如果没有安装 Powerpoint,我希望能够使用 Powerpoint Viewer。
There seems to be some ActiveX-controls that allows integration of Powerpoint in a form, but most of these seem to cost money, does anyone have experience using one of these controls?
似乎有一些 ActiveX 控件允许在表单中集成 Powerpoint,但其中大多数似乎要花钱,有人有使用这些控件之一的经验吗?
Edit: I know that there is an object model accessable by adding a reference to Microsoft.Office.InterOp.Powerpoint, but I want to be able to distribute the resulting program without having Microsoft Office as a prerequisite, that was why I mentioned Powerpoint Viewer because it can be distributed freely.
编辑:我知道有一个对象模型可以通过添加对 Microsoft.Office.InterOp.Powerpoint 的引用来访问,但我希望能够在不将 Microsoft Office 作为先决条件的情况下分发结果程序,这就是我提到 Powerpoint Viewer 的原因因为它可以自由分发。
采纳答案by Anonymous Type
This kb lays out the basics for working with the powerpoint presentation viewer object model. I'd suggest you include the viewer when you distribute your application.
此知识库列出了使用 powerpoint 演示文稿查看器对象模型的基础知识。我建议您在分发应用程序时包括查看器。
http://support.microsoft.com/kb/265385
http://support.microsoft.com/kb/265385
Once you get a reference to the viewer (top level) object it is basically the same as working with the powerpoint.presentation object model, but with less functionality (i.e. editing, etc)
一旦获得了对查看器(顶级)对象的引用,它与使用 powerpoint.presentation 对象模型基本相同,但功能较少(即编辑等)
If you are working with Powerpoint 2007, then you can add editing functionality by using the System.XML and related namespaces to work with the presentation file as an open xml file.
如果您使用的是 Powerpoint 2007,则可以通过使用 System.XML 和相关命名空间来添加编辑功能,以将演示文稿文件作为打开的 xml 文件进行处理。
Regarding the comments about UNO/openoffice.org, I think these miss the point, as you cannot use UNO for working with powerpoint, it is for openoffice and that was not the origianl requirement of the questioner.
关于 UNO/openoffice.org 的评论,我认为这些都没有抓住重点,因为你不能使用 UNO 来处理 powerpoint,它是针对 openoffice 的,这不是提问者的原始要求。
there are 3rd party toolsets like aspose, but then your goal was to work with the powerpoint viewer component (free) so I'm guessing you want to avoid paying for dev tools? Either way viewer components OM is perfectly suitable for displaying and previewing and existing slide show. (you will need one copy of Powerpoint so that you can author the presentation from scratch, plus Visual Studio to create the VSTO project).
有像 aspose 这样的 3rd 方工具集,但是您的目标是使用 powerpoint 查看器组件(免费),所以我猜您想避免为开发工具付费?无论哪种方式,查看器组件 OM 都非常适合显示和预览现有幻灯片。(您将需要一份 Powerpoint 副本以便您可以从头开始创作演示文稿,并需要使用 Visual Studio 来创建 VSTO 项目)。
回答by David Holm
One of our softwares here at work does that. Initially we used MS Office but recently we switched to use OpenOffice.org Unosince it offers better control than MS Office and is easier to work with. It has .NET CLI-bindings.
我们在这里工作的一个软件就是这样做的。最初我们使用 MS Office,但最近我们转而使用OpenOffice.org Uno,因为它比 MS Office 提供更好的控制并且更易于使用。它具有.NET CLI 绑定。
To answer your question, yes it can be done but our engineers would recommend you use OpenOffice.org instead.
要回答您的问题,是可以做到的,但我们的工程师会建议您改用 OpenOffice.org。
回答by Lou Franco
I have used the Word toolkit from Aspose -- they have a Powerpoint toolkit too that I think would be worth looking at.
我使用了 Aspose 的 Word 工具包——他们也有一个 Powerpoint 工具包,我认为值得一看。
http://www.aspose.com/categories/file-format-components/aspose.slides-for-.net-and-java/default.aspx
http://www.aspose.com/categories/file-format-components/aspose.slides-for-.net-and-java/default.aspx
回答by Ian Andrews
Just like with Microsoft Excel and Word, Powerpoint has an Object Model that you can access in code by including a reference in your project to:
就像 Microsoft Excel 和 Word 一样,Powerpoint 有一个对象模型,您可以通过在项目中包含一个引用来在代码中访问它:
Microsoft.Office.InterOp.Powerpoint.
Microsoft.Office.InterOp.Powerpoint。
I've used the Excel and Word models, but haven't used the one for Powerpoint. You can get a little taste of what's available by opening up the Object Browser once you've included the reference to see what kind of functionality is available. This might be a viable solution for you if you don't want to use a 3rd party tool to access the object model.
我使用过 Excel 和 Word 模型,但没有使用过 Powerpoint 模型。您可以在包含参考后打开对象浏览器来了解可用的功能,以了解可用的功能类型。如果您不想使用 3rd 方工具访问对象模型,这对您来说可能是一个可行的解决方案。