您好我如何使用c#.net在Windows应用程序中显示word文件 [英] Hi how can i display word file in windows application using c#.net

查看:49
本文介绍了您好我如何使用c#.net在Windows应用程序中显示word文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:



Hi this is my code:

private void button1_Click(object sender, EventArgs e)
{
    String strFileName;

    //Find the Office document.
    openFileDialog1.FileName = "";
    openFileDialog1.ShowDialog();
    strFileName = openFileDialog1.FileName;

    //If the user does not cancel, open the document.
    if (strFileName.Length != 0)
    {
        Object refmissing = System.Reflection.Missing.Value;
        oDocument = null;
        webBrowser1.Navigate(strFileName);
    }
}





这里我用webbrowser控件加载word文档文件。但是这个代码没有加载我的应用程序中的wordfile ...这里我的文档文件单独显示..请告诉我如何使用c#windows应用程序在我的webbrowser控件中加载word文档。



here i used webbrowser control for loading word document files.but this code not load a wordfile in my application...here my document file displayed separately..so please tell how can i load word documents in my webbrowser control using c# windows application.

推荐答案

要显示Word文档,您需要嵌入Word OCX并阅读其文档。显然,这要求用户的机器上有Word。 Web浏览器(包括WebBrowser对象中的IE)通常会启动外部程序来打开此类文档。
To display a Word document you need to embed the Word OCX and read its documentation. Obviously, this requires that the user's machine has Word on it. A web browser, including the IE in the WebBrowser object, will typically start an external program to open this kind of document.


不好主意。 Word是一种专有产品。不仅客户需要支付许可费用,还会有供应商锁定( http://en.wikipedia .org / wiki / Vendor_lock-in [ ^ ])关于产品,没有兼容性,没有什么好处。



想想:1)HTML; 2) System.Windows.Forms.RichTextBox ; 3) System.Windows.Controls.RichTextBox ; 4)WPF流文档; 5)别的东西。



请参阅:

http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/ system.windows.controls.richtextbox.aspx [ ^ ],

http: //msdn.microsoft.com/en-us/library/aa970909.aspx [ ^ ]。







同时,禾rd文件格式兼容性是更容易的问题。毕竟,OpenOffice,LibreOffice和其他产品支持所有版本的格式,请参阅:

http ://en.wikipedia.org/wiki/OpenOffice.org [ ^ ],

http://en.wikipedia.org/wiki/LibreOffice [ ^ ]。



如果您只想支持较新的Office Open XML,则格式本身可用,并在ECMA-376和ISO / IEC 29500:2008下标准化:

http://en.wikipedia.org/wiki/Office_Open_XML [ ^ ],

http://en.wikipedia.org/w iki / Office_Open_XML_software [ ^ ]。



请参阅Office Open XML软件的对比图表:

http://en.wikipedia.org/wiki/Comparison_of_Office_Open_XML_software [ ^ ]。



由于某些源代码可用且已打开,您可以使用它。



-SA
Bad idea. Word is a proprietary product. Not only the customers will have to pay for the license, there would be a vendor lock-in (http://en.wikipedia.org/wiki/Vendor_lock-in[^]) on the product, no compatibility, nothing good.

Think about: 1) HTML; 2) System.Windows.Forms.RichTextBox; 3) System.Windows.Controls.RichTextBox; 4) WPF Flow Document; 5) something else.

Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.aspx[^],
http://msdn.microsoft.com/en-us/library/aa970909.aspx[^].



At the same time, Word file format compatibility is the easier problem. After all, OpenOffice, LibreOffice and other products support all versions of the format, please see:
http://en.wikipedia.org/wiki/OpenOffice.org[^],
http://en.wikipedia.org/wiki/LibreOffice[^].

If you would like to support only the newer Office Open XML, the format itself is available and is standardized under ECMA-376 and ISO/IEC 29500:2008:
http://en.wikipedia.org/wiki/Office_Open_XML[^],
http://en.wikipedia.org/wiki/Office_Open_XML_software[^].

Please see the comparison chart on Office Open XML software:
http://en.wikipedia.org/wiki/Comparison_of_Office_Open_XML_software[^].

As some source code is available and open, you can use it.

—SA


您好,

请参阅类似讨论的链接:

如何使用Web浏览器控件在dot net windows应用程序中显示word文件 [ ^ ]









--Amit
Hi,
Refer the link for similar discussion:
How to display word file in dot net windows application using web browser control[^]




--Amit


这篇关于您好我如何使用c#.net在Windows应用程序中显示word文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆