如何在My C#应用程序中嵌入MS Word? [英] How to embed MS Word in My C# application?

查看:58
本文介绍了如何在My C#应用程序中嵌入MS Word?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在我的表单中嵌入MS Word ..所以我搜索并找到这段代码:

Hi,
I want to embed MS Word in my form.. So I searched and find this code :

Add a COM reference : Microsoft Office 12.0 Object Library

 
Then add the following namespace :
 
using Microsoft.Office;
using office = Microsoft.Office.Interop.Word;
 
And then in the code where you want to use, add this :
 
var wordApp = new office.Application();
Document document=wordApp.Documents.Open(//Specify the parameters)





但我没有找到微软.Office.Interop.Word; Office中唯一的类是Core ...



我正在使用.NET Framework 4.0;



如何在Windows窗体中嵌入MS字?



问候:

Jayanta。



谢谢高级..



But I don't find the Microsoft.Office.Interop.Word; the only class have in Office is Core...

I'm using .NET Framework 4.0;

How do I embed MS word in windows Form??

Regards :
Jayanta.

Thanks In Advanced..

推荐答案

我不相信你可以。 Interop库旨在用于与MS Office文档交互并自动化MS Word,但不能嵌入它。要使用这些库,必须在运行该程序的计算机上安装Office。换句话说,它不是免费的MS Word票证,Office必须在您的计算机上才能在GAC中安装组件。
I don't believe you can. The Interop libraries are meant to be used to interact with MS Office documents and to automate MS Word, but not to embed it. In order to use the libraries, you must have Office installed on the computer that the program is running on. In other words, its not a free MS Word ticket, Office has to be on your computer for the components to be installed in the GAC.


看起来这是不可能的,因为一个主导因素:Microsoft Office的商业特性及其许可。



这就是说,这不仅是一个问题,可能不会有一个令人满意的解决方案,但你也不应该试着这样做。您可以从不同的角度查看问题:您可能需要一个能够读取/写入某些Office文档的非Microsoft组件。这看起来更真实。



我所知道的唯一开源代码是OpenOffice本身(其中.odt来自)和它的 fork LibreOffice的。请参阅:

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

http://www.openoffice.org/ [ ^ ],

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

http://www.libreoffice.org/ [ ^ ]。







您可以在C#应用程序中使用LibreOffice组件,因为有用于CLI的LibreOffice SDK:

http://api.libr eoffice.org/examples/examples.html [ ^ ],

http://api.libreoffice.org/examples/examples。 html#CLI_examples [ ^ ]。







您可以从关于CLI绑定的LibreOffice文档开始:

http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO / CLI / CLI_Language_Binding [ ^ ]。



此处列出了您需要引用的LibreOffice绑定程序集:

http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/Language_Binding_DLLs [
依旧......



-SA
It looks like this is not possible due to one dominating factor: commercial character of Microsoft Office and its licensing.

That said, not only this is a problem which probably won't have a satisfactory solution, but you also should not try to approach it like that. You can look at the problem from a different perspective: you may need a non-Microsoft component capable of reading/writing some Office documents. And this looks more realistic.

The only open-source code I know is OpenOffice itself (where .odt came from) and its fork LibreOffice. Please see:
http://en.wikipedia.org/wiki/OpenOffice.org[^],
http://www.openoffice.org/[^],
http://en.wikipedia.org/wiki/LibreOffice[^],
http://www.libreoffice.org/[^].



You can use LibreOffice components in your C# application because there is such thing as LibreOffice SDK for CLI:
http://api.libreoffice.org/examples/examples.html[^],
http://api.libreoffice.org/examples/examples.html#CLI_examples[^].



You can start with LibreOffice documentation on CLI binding:
http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/CLI_Language_Binding[^].

The LibreOffice binding assemblies you need to reference are listed here:
http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/Language_Binding_DLLs[^].

And so on…

—SA


没有免费的组件据我所知,所以你唯一的选择是寻找第三方控制。我知道DevExpress有一些Rich Text Editor(我认为它们也为WinForms提供了一个)以及Tx Text Control。而且我打赌还有更多的东西。
There is no a free component as far as I know so your only option is to look for a 3rd party control. I know DevExpress has some kind of Rich Text Editor (I think they also provide one for WinForms) as well as Tx Text Control. And I bet there are some more out there.


这篇关于如何在My C#应用程序中嵌入MS Word?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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