.NET Efficient way to generate WORD Doc - Server Side

烈酒焚心 提交于 2019-12-02 00:05:41

问题


.NET 4.0

I am looking for the easiest way to generate a Word document on our server.

Limitations :

  • Server side
  • I don't want to install word on the server
  • Data source is XML

I tried to generate a DOCX with XSLT which is fast and easy but the only way I could find to validate the generated document is to open it with Word and the only error I get when the document is not valid is "Error while opening document". Not very useful.

Any ideas?

Thanks, Alex


回答1:


You have two options given your setup.

  1. Use a third party library, something like the stuff available from SyncFusion
  2. Use the XML route, the initial setup isn't fun, but once you get it the process is easy.

A third, much more crude way would be to write an HTML file and save as .doc, but that is going to cause warnings on the user side with 2007 and later.




回答2:


Keeping far from office automation at server side is really a good idea (since even Microsoft does not support this scenario).

I have never used, but this lib looks promising. Have you tried it?




回答3:


I have used the Word interops, but I hated it. Stick processes, etc!

I found that generating HTML and saving as file with .DOC extension worked better than anything.




回答4:


A few years back, I worked on a project which used Aspose Word (http://www.aspose.com/categories/.net-components/aspose.words-for-.net/default.aspx) to generate Word documents. The tool does not require Word to be installed. However, it is not a cheap tool. IT tool was relatively easy to use and has a robust .net interface.



来源:https://stackoverflow.com/questions/2961227/net-efficient-way-to-generate-word-doc-server-side

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!