简体   繁体   English

用于生成docx文件的库(Open XML)

[英]Libraries to generate docx files (Open XML)

We need to generate docx documents from an asp.net mvc site. 我们需要从asp.net mvc站点生成docx文档。 The documents will vary a great deal, but they are pretty basic - the only thing out of the ordinary is the need to include tables. 这些文件会有很大差异,但它们非常基本 - 唯一不同寻常的是需要包含表格。 The c# code that generates the documents will need to create similar html/css as well. 生成文档的c#代码也需要创建类似的html / css。 We don't have time to buy a commercial product for this. 我们没有时间为此购买商品。

Should we just read the spec and write some code to spit out the XML, or are there libraries available that would do the trick? 我们应该只阅读规范并编写一些代码来吐出XML,还是有可用的库可以解决问题?

Edit: looks like Microsoft's Open XML library is an obvious choice, but does anyone have any experience with it? 编辑:看起来像微软的Open XML库是一个明显的选择,但有没有人有任何经验呢? And can anyone point to some sample code that uses it? 任何人都可以指出一些使用它的示例代码吗?

Try this... http://openxmlwriter.codeplex.com/ 试试这个... http://openxmlwriter.codeplex.com/

codeplex.com has a lot of other libraries too. codeplex.com也有很多其他库。

http://www.codeplex.com/site/search?query=openxml http://www.codeplex.com/site/search?query=openxml

You can try https://github.com/open-xml-templating/docxtemplater 您可以尝试https://github.com/open-xml-templating/docxtemplater

It makes it possible to create a template written in docx, that contains tags Hello {name} tha will be replaced. 它可以创建一个用docx编写的模板,其中包含将被替换的标签Hello {name}

You also have the possibility to create tables by looping over the table columns. 您还可以通过循环表列来创建表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM