将数据库(sql server 2008)中的数据填充到word(word 2007 /模板)的最佳方法是什么?
我需要从数据库(MS SQL server 2008)读取数据并将它们推送到Word文档(Office 2007)中。最好、最快的方法是什么?我在这里阅读了有关该问题的信息:support.microsoft.com/kb/316384 和此处:msdn.microsoft.com/en-us/library/aa192487(office.11).aspx。我试图了解 fleXdoc 的使用,但几乎没有文档。我不需要在服务器上使用它,我想在本地生成。我将从模板生成最多 10 个单独的文档,每个文档最多 5 页。 (例如发票)。请有人指出一些操作方法或示例项目,因为我找不到有用的东西。非常感谢。
I need to read data from my DB (MS SQL server 2008) and push them into Word document (Office 2007). What is the best and fast way to do it? I have read about the problem here : support.microsoft.com/kb/316384 and here : msdn.microsoft.com/en-us/library/aa192487(office.11).aspx. I have tried to understand also use of fleXdoc, but there is almost no documentation. I do not need to use it on server, i want generate locally. I will generate maximally 10 separate documents from template at maximum 5 pages per each. (Invoice for example). Please can someone point to some how-to or sample project, as i am unable to find something usefull. Thank`s a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议您输出文本文件(例如 CSV),并将其用于 Word 的合并数据文件。
I suggest you output text files, CSV for example, and use those for your merge data files for Word.
您可以使用 CustomXML 数据绑定,但您可能需要能够处理重复的数据行。这是可以做到的(请参阅 http://dev .plutext.org/svn/docx4j/trunk/docx4j/sample-docs/databinding/conventions.html ),但对于您的场景来说可能有点过头了。
为您的数据表创建一个 HTML 文档,并将其作为 altChunk 包含在您的 Word 文档中怎么样?请参阅 http://blogs.msdn.com/b/ericwhite/archive/2008/10/27/how-to-use-altchunk-for-document- assembly.aspx
这两种方法都适用于 Word 2007 或后来,使用docx(Open XML)作为文档格式。
You could use CustomXML databinding, but you will likely need to be able to handle repeating rows of data. That can be done (see http://dev.plutext.org/svn/docx4j/trunk/docx4j/sample-docs/databinding/conventions.html ), but may be overkill for your scenario.
What about making an HTML document for your data table, and including that in your Word document as an altChunk? See http://blogs.msdn.com/b/ericwhite/archive/2008/10/27/how-to-use-altchunk-for-document-assembly.aspx
Both of these approaches work with Word 2007 or later, using docx (Open XML) as the document format.
但需要注意的是,该方法可能不适用于 Office 2010。由于有关该技术的诉讼,MS 不得不从 Word 中删除大量自定义 XML 合并内容。 Office 2007 和 2010 的更新删除了部分 XML 支持。
Something to be aware of however, the approach might not work with Office 2010. MS Had to remove a lot of the Custom XML merging stuff from Word as a result of a lawsuit about the technology. Updates to Office 2007 and definitely 2010 have some parts of that XML support removed.