生成从C#的Word文档

问题描述:

可能重复:结果
如何在Word文档中C#创建?

在我的应用程序之一,我需要生成从C#代码的Word文档。就像我们使用的是SQL数据库,我们存储从升C代码,SQL数据库的库存数据。

In one of my application i need to generate the word document from the C# code. like we are using the sql as database and we are storing the inventory data from the c sharp code to sql database.

有第三方库的帮助,但是如果你想自己开发一个解决方案,你可能想弄个打开XML SDK

There are third-party libraries to help, but if you want to develop a solution yourself, you may want to get hold of the Open XML SDK.

我建议,而不是创建完全代码的Word文档,您使用Microsoft Word创建,然后使用Open XML SDK修改的模板文件。

I recommend that rather than creating a Word document completely in code, you create a template document using Microsoft Word and then modify it using the Open XML SDK.

不要试图使用Word自动化如果你生产服务器上的文档。除了不支持存在,它有点容易出现资源问题。

Don't be tempted to use Word Automation if you're producing the document on a server. Apart from being unsupported, it's somewhat prone to resource issues.

我的博客前一段时间关于插入图像到Word使用Open XML文档。

I blogged some time ago about inserting images into Word documents using Open XML.