生成的Word文档用C# [英] Generating a Word Document with C#

查看:244
本文介绍了生成的Word文档用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定的邮件地址的列表,我需要打开现有的Word文档,它的格式设置为打印标签,然后将每个地址到表的不同单元格。当前的解决方案将打开Word应用程序和将光标移动到插入的文本。然而,阅读从一个Web应用程序中打开新版本的Word中的安全问题和存在的问题后,我决定,我需要使用其他方法。

Given a list of mailing addresses, I need to open an existing Word document, which is formatted for printing labels, and then insert each address into a different cell of the table. The current solution opens the Word application and moves the cursor to insert the text. However, after reading about the security issues and problems associated with opening the newer versions of Word from a web application, I have decided that I need to use another method.

我已经调查使用的Office Open XML,但我没有发现任何好的资源,提供有关如何正确地使用它的具体信息。此外,有人建议我使用SQL报告服务,但对如何使用它们,使我无处寻找的信息。

I have looked into using Office Open XML, but I have not found any good resources that provide concrete information on exactly how to use it. Also, someone suggested that I use SQL reporting services, but searching for information on how to use them, lead me nowhere.

哪种方法,你认为是最适合我的问题?

Which method do you think is the most appropriate for my problem?

code的例子和链接,很好的教程将是非常有益的。

Code samples and links to good tutorials would be extremely helpful.

推荐答案

感谢所有的答案,但我真的不想支付一个插件,使用Word的自动化是不可能的。所以,我一直在寻找,最终,通过一些试验和错误,找到了一些答案。

Thanks for all the answers, but I really did not want to pay for a plugin and using Word automation was out of the question. So I kept searching and eventually, through some trial and error, found some answers.

在通过微软的网站上透了搜索,我发现在的Office Open XML SDK一些较新的文章。我下载了新的工具和刚刚开始经历他们每个人。

After throughly searching through Microsoft's site, I found some newer articles on the Office Open XML SDK. I downloaded the new tools and just started going through each them.

然后我找到了文档反射器,它基于关闭现有的Word文档创建一个类来生成XML code(.DOCX)。使用我的标签模板文件和C产生的这个工具的$ C $,我经历了,并补充说,附加的表单元格为每个地址一个循环。它实际上被证明是相当简单和方式比使用Word自动化的速度更快。

I then found the Document Reflector, which creates a class to generate XML code based off an existing Word Document (.docx). Using my Label Template Document and the code this tool generated, I went through and added a loop that appends table cells for each address. It actually proved to be fairly simple and way faster than using Word automation.

所以,如果你还在使用Word自动检查出的Office Open XML工具。他们令人惊讶的广泛从微软免费下载。

So, if you're still using Word automation check out the Office Open XML tools. Their surprisingly extensive for a free download from Microsoft.

<一个href="http://www.microsoft.com/downloads/details.aspx?FamilyId=C6E744E5-36E9-45F5-8D8C-331DF206E0D0&displaylang=en"相对=nofollow>的Office Open XML SDK 2.0下载

这篇关于生成的Word文档用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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