任何人都知道如何制作一个或如何下载控件来查看PowerPoint文档?Powerpoint Viewer控件C#/ VB/.NET
我查过了,但是唯一出现的是this,这绝对不是免费的。我相信微软必须拥有一个能够做到这一点的控制。
做一个控制,做它也欢迎。
任何人都知道如何制作一个或如何下载控件来查看PowerPoint文档?Powerpoint Viewer控件C#/ VB/.NET
我查过了,但是唯一出现的是this,这绝对不是免费的。我相信微软必须拥有一个能够做到这一点的控制。
做一个控制,做它也欢迎。
这里有我正在寻找的问题的解决方案。 如果任何人有同样的问题,我离开这里后,我做了很多小时的工作后,我的解决方案。
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
static extern IntPtr FindWindow(IntPtr ZeroOnly, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool SetWindowText(IntPtr hwnd, String lpString);
private string FileName = "";
PowerPoint.Application application;
PowerPoint.Presentation presentation;
bool flag = false;
public UserControl1()
{
InitializeComponent();
}
public void open()
{
sair();
openFileDialog1.Filter = "Powerpoint file (*.ppt)|*.ppt|All files (*.*)|*.*";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
FileName = openFileDialog1.FileName;
IntPtr screenClasshWnd = (IntPtr)0;
IntPtr x = (IntPtr)0;
flag = true;
application = new PowerPoint.Application();
presentation = application.Presentations.Open2007(FileName, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue);
PowerPoint.SlideShowSettings sst1 = presentation.SlideShowSettings;
sst1.ShowType = (PowerPoint.PpSlideShowType)1;
PowerPoint.SlideShowWindow sw = sst1.Run();
sw.Height = (panel1.Height) - 64;
sw.Width = (panel1.Width) - 130;
IntPtr formhWnd = FindWindow(x, "Form1");
IntPtr pptptr = (IntPtr)sw.HWND;
screenClasshWnd = FindWindow(x, "screenClass");
SetParent(pptptr, panel1.Handle);
this.Focus();
this.application.SlideShowEnd += new Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowEndEventHandler(SlideShowEnds);
}
}
中链接了什么嗨,这看起来非常有趣@NickHalden,但我看不出有些东西在哪里定义,例如sair()方法? – KingCronus 2012-07-08 10:29:03
最简单的方法是使用PowerPoint Interop名称空间。你可以在MSDN site上阅读。一个警告,是它需要你安装PowerPoint。所以,如果这将用于商业软件,那么这将是没有实际意义的,因为客户不得不购买PowerPoint。但是对于许多任务来说,它很漂亮,而.NET 4.0使得MS Office的工作变得简单。
我已经使用PowerPoint Interop,但它不是我想要的。 我想用ppt查看器将其嵌入到c#窗口中,唯一的方法是创建或使用ppt查看器作为控件。 PowerPoint Interop创建PowerPoint实例并使用全屏显示。 – diogopalhais 2012-03-08 18:03:19
@NickHalden然后我会建议看看Davide Piras在评论 – Jetti 2012-03-08 18:40:54
这被讨论过很多次,最好的办法似乎是使用Web浏览器控件来显示PPT文件,见前面的问题,例如:http://stackoverflow.com/questions/1259369/embed-powerpoint-viewer -in-c-sharp-win-form – 2012-03-08 17:11:48