如何使用C#.NET打开word文档作为Mdi子表单 [英] How to open word document as Mdi child form using C#.NET

查看:124
本文介绍了如何使用C#.NET打开word文档作为Mdi子表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Word中打开word文档作为MdI child to mdi Parent form C#

解决方案

没有公共组件即用型组件来呈现Word我知道的文件。这是不太可能的,因为Word是一个专有的应用程序。一般来说,我认为关于Word的众多问题反映了非开发人员对问题的处理方法,但普通计算机使用的方法仍然不能很好地理解谁是谁。使用其他类型的文档会更好,例如Microsoft Flow Document,HTML等。



有一些用C ++编写,是LibreOffice的一部分/开发办公室。如果您只需要在屏幕上呈现文档,原则上您可以通过P / Invoke使用C ++代码。或者您可以从头开始实现.NET组件,但这将是一项巨大的工作。但是,如果您想使用较新的Microsoft Office XML-based格式,这很有可能,因为它在ECMA-376下标准化:

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

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

http://www.ecma-international.org/publications/standards/Ecma- 376.htm [ ^ ]。



或者,您可以解析Office文档,而不是完全成熟的实现。它是一些其他文档结构,没有一对一的对应关系,并呈现它。这种方法在某些网站上是典型的,使用Office< - > HTML映射 - 例如,查看职业网站。 (对于Forms,CodeProject有一个很棒的秘密武器! - 请看这篇文章:您将使用的专业HTML渲染器 [ ^ ]。)



另见我过去的答案:

将Office文档转换为PDF,无需互操作 [ ^ ],

他如何使用c#.net [ ^ ]。



最后,请注意MDI。以下是这个想法:谁需要MDI?为什么要折磨自己并吓跑你的用户?

帮自己一个大忙:根本不要使用MDI。没有它,您可以更轻松地实现设计,质量更好。 MDI甚至被微软高度劝阻,事实上,微软将其从WPF中删除并且很难支持它。更重要的是,如果您使用MDI,您将吓跑所有用户。只是不要。请参阅:

http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages [ ^ ],

如何在WPF中创建MDI父窗口? [ ^ ]。



我可以解释做什么。请查看我过去的答案:

关于在WPF中使用MDI窗口的问题 [ ^ ],

MDIContainer给出错误 [ ^ ],

如何设置最大化的子窗体,最小化最后一个子窗体 [ ^ ]。



-SA

How to open the word document as MdI child to mdi Parent form in C#

解决方案

There is no a public component ready-to-use component to render Word document I'm aware of. This is very unlikely, because Word is a proprietary application. In general, I think that the numerous questions about Word reflect non-developer's approach to the problem, but the approach of plain computer uses still not understanding well who is who. It would be much better to use documents of other types, such as Microsoft Flow Document, HTML or the like.

There are some written in C++, a part of LibreOffice/OpenOffice. If you only need to render the document on screen, in principle you can use C++ code through P/Invoke. Or you can implement .NET components from scratch, but it will be a huge work. However, this is quite possible if you want to use newer Microsoft Office XML-bases format, because it is standardized under ECMA-376:
http://en.wikipedia.org/wiki/Office_Open_XML[^],
http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats[^],
http://www.ecma-international.org/publications/standards/Ecma-376.htm[^].

Alternatively, instead of fully-fledged implementation, you can parse Office document, map it so some other document structure, without one-to-one correspondence, and render it. This approach is typical on some Web sites, with Office<—>HTML mapping — for example, look at career sites. (And for Forms, CodeProject has a wonderful "secret weapon"! — see this article: A Professional HTML Renderer You Will Use[^].)

See also my past answers:
Convert Office-Documents to PDF without interop[^],
Hi how can i display word file in windows application using c#.net[^].

And finally, let me note on MDI. Here is the idea: who needs MDI, ever? Why torturing yourself and scaring off your users?
Do yourself a great favor: do not use MDI at all. You can do much easier to implement design without it, with much better quality. MDI is highly discouraged even by Microsoft, in fact, Microsoft dropped it out of WPF and will hardly support it. More importantly, you will scare off all your users if you use MDI. Just don't. Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
How to Create MDI Parent Window in WPF?[^].

I can explain what to do instead. Please see my past answers:
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to set child forms maximized, last childform minimized[^].

—SA


这篇关于如何使用C#.NET打开word文档作为Mdi子表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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