需要内置“邮件合并”的.NET应用程序 功能性
有什么方法可以在我的应用程序中拥有邮件合并功能吗? 也许是 MS Word API?
Is there some way to have the Mail Merge capability in my application? Maybe a MS Word API?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这个(尚)不支持 doc 或 docx,但支持 RTF。 另一方面,它是免费的:)并且我正在积极努力不断增强它。
看一下,可能对你的情况有用。 ntemplates.codeplex.com
This one does not support (yet) doc or docx but it supports RTF. On the other hand, it's free :) and I'm actively working on enhace it more and more.
Take a look, may be useful in your case. ntemplates.codeplex.com
是的,您使用 Word Automation:
http://support.microsoft.com/kb/301659
Yeah, you use Word Automation:
http://support.microsoft.com/kb/301659
我已经使用 Microsoft Word 的第三方库实现了它: Aspose Words。
有一些 邮件合并内置功能。 您不需要在客户端或服务器上安装 Microsoft Word 的副本。
I've implemented it using a third-party library for Microsoft Word: Aspose Words.
There are some mail merge built-in functions. You won't need an installed copy of Microsoft Word on the client or server.
您可以编写自己的功能,也许可以从数据生成 XML(XmlSerialization 可能是您的朋友),并使用 XSLT 转换来生成选择的输出格式(如果您愿意,可以是 HTML,甚至可以直接用于 Word 的 XML 格式)。 Office 集成可能会有所帮助,但它可能不会给您的应用程序带来最集成的感觉。
该决定取决于谁将创建模板 - 如果您只想要预先设计的模板,那么选择更加开放 - 如果您希望最终用户创建它们,您可能只想创建一种友好的生成方式(例如)用于 Word(或他们最喜欢的文字处理器)的 CSV 导入并进行邮件合并。
You could write your own functionality, maybe generating XML from your data (XmlSerialization could be your friend here) and using an XSLT transform to generate the output format of choice (HTML if you like, or even the XML formats direct for Word). The office integration might be of help, but it might not give the most integrated feel to your application.
The decision hinges on who'll be creating the templates -- if you just want predesigned ones, then the choice is more open -- if you want your end users to be creating them, you might just want to create a friendly way of generating (say) CSV for Word (or their favorite Word processor) to import and do the mail merge with.
我不建议使用 MS Word 来提供邮件合并功能,除非您的应用程序已经绑定到 MS Word API。 仅仅因为这个原因而使用它将会是一个你可能会后悔的决定——就像我后悔几年前所做的那样。 虽然大多数人确实拥有 MS Word,但您最终将支持 Word、邮件合并界面和您的应用程序,而只能真正控制您的应用程序。 即使界面在您的计算机上完美运行(就像在我们的计算机上运行一样),您也可能会发现很多很多人的界面根本无法运行。 请记住,如果您的应用程序很受欢迎,即使 3% 的失败率也可能会转化为数千次调用!
如果可能的话,使用第三方库/控件来进行您自己的邮件合并以进行文字处理。
祝你好运!
I would not recommend using MS Word to provide a mail merge capability unless your application is already tied in to the MS Word API. Using it for just that one reason will be a decision that you are likely to regret - just as I regretted having done it a few years back. While it is true that most people have MS Word, you will end up supporting Word, the mail-merge interface, and your application while only really having control over your application. Even if the interface works perfectly on your computers (as it worked on ours) you are likely to find many, many people for whom your interface doesn't work at all. Remember, even a 3% failure rate may translate to thousands of calls if your application is popular!
If at all possible, roll your own mail merge using a third-party library/control for the word processing.
Good luck!