在 Ruby 中以编程方式输出 Word 文档格式的文件的最佳方法是什么?
我需要根据应用程序中的一些文本内容从基于 Ruby 的 Web 应用程序 (Rails/Sinatra) 输出 Word 文档格式的文件。 Ruby 中是否有用于创建和构建 Word 文档的库支持?
I need to output a file in the format of a Word document from a Ruby-based web app (Rails/Sinatra) based on some textual content in the app. Is there library support in Ruby for creating and structuring a Word document?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看 XML 格式 WordML对于 Word 文件。
John Durant 的博客提供了有用的WordML 和常见问题解答资源列表
演练:Word 2007 XML 格式
用于创建 XSLT 转换的有用工具:Office 2003 工具:WordprocessingML转换推理工具
这些 SO 帖子可能也令人感兴趣:
Take a look at WordML, the XML format for Word files.
John Durant's blog has a useful list of WordML and FAQ resources
Walkthrough: Word 2007 XML Format
Useful tool for creating XSLT transforms: Office 2003 Tool: WordprocessingML Transform Inference Tool
These SO posts might also be of interest:
您没有具体说明“Word 文档”的确切含义。 它是 Word 2003 风格的 doc 文件吗? 它是 Word 2007 docx 文件吗? 它只是 Word 可以打开而不支持样式的东西吗?
如果您想要后者,您可以使用 RTF,这比 doc 格式更容易一些。 有一个名为 Ruby RTF 的库,它应该可以满足您的需求,尽管老实说我从未使用过我自己。
You don't specify what "a Word document" means exactly. Is it a Word 2003-style doc file? Is it a Word 2007 docx file? Is it just something Word can open than supports styling?
If the latter is what you want, you could use RTF, which is somewhat easier than the doc format. There is a library called Ruby RTF that should do what you want, though I've honestly never used it myself.
生成 Word 2003 文档会更容易吗:是否有一种更容易理解的基本 Word 2003 .doc 文件格式,不需要 XML 等方面的博士学位?
Would it be easier to generate a Word 2003 document: Is there an easier to understand file format for a basic Word 2003 .doc that doesn't require a PhD in XML, etc?