开发者

Word document generation

Our product is going to support Word(and PDF) report generation, and I'm investigating on which techniques to choose.

Currently what I know is Word automation and OpenXML SDK. There are pros & cons of each.

Do you have any experiences, suggestions or comments about these two or any other techniques? Or is there any third-party utilities/products(may be based on the previ开发者_如何学编程ous two techniques or not) we can use? We want to analyze as many possible solutions as possible.


If you have the choice I'd go for OpenXML any day of the week. It has quite a number of advantages over Office Automation.

The most interesting one for me is the fact that it can run on a server, where Office Automation can't (because you need an instance of office on the pc/server running your software). That brings us to my second point, it doesn't need an instance of Office to generate your documents, where Office automation needs one. (This is because office automation will run an instance of office in the background and perform all your actions on it).

Especially when we are talking about large documents or being able to generate quite a few at the same time, OpenXML will perform a lot better than Office Automation because of this.

To make a long story short, Office automation is a thing of the past, openXML is the future ;)

If you want to dive into OpenXML, take a peek here: OpenXML Developer

Good luck !


For PDF generation I used http://www.html-to-pdf.net in past. This provides good support and I assume can be used to generate word documents as well... Check out there website...

If you are using Web forms, I faced one issue with HTTPS - which I listed the solution here:

http://blogs.msdn.com/b/sajoshi/archive/2010/12/13/using-pdfconverter-http-www-html-to-pdf-net-with-https-in-asp-net-mvc.aspx


Docmosis offers a cloud service that can produce MS Word and PDF output via a simple api. The report or document templates are either Word or Open Office documents which can be edited and maintained by non-developers. Once uploaded to the system your application can then simply call the service and specify the data to inject into the document(s) as either JSON or XML. The result is then streamed back, emailed, or placed in storage for access later. Output can be doc, pdf, or html.

The service offers a wide range of templating features and so supports quite complex reporting requirements.

The best thing we found was that cosmetic changes to the output could be handled by the document authors and not the developers which saved us heaps of valuable time (not to mention saving the sanity of our developers).

www.docmosis.com


If you want to build your documents in code, the OpenXML SDK is definitely the way to go. It is a very well designed API that makes full use of LINQ type syntax. One you're up to speed on it you will find it very powerful and easy to use.

With that said, you then have all the logic of your document in code. And change requires a change in your code and that tends to become a pain over time. If you want a system where you design the document in Word you've got a couple of choices - and Word automation is the worst. Even Microsoft says don't do Office automation on a server.

One of the best choices where you design in Word is Windward Reports (disclaimer - I'm the CTO there). With Windward you get the power and ease of Word for your design and new documents or revisions of existing documents don't require a change in code. Other products that take this approach are XpertDoc and SoftArtisans (although both of them do have a code component with each template).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜