且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ColdFusion - 将 HTML 网页转换为 Word 或 PDF 文档

更新时间:2023-02-12 21:28:53

对于 MS Word 要求,大多数版本的 Office 可以解释基本的 html/xml.因此,您可能会将旧的 cfcontent hack 视为 POI 的更简单替代方案.(Word 包不如电子表格包成熟.)

For the MS Word requirement, most versions of Office can interpret basic html/xml. So you might consider the old cfcontent hack as a simpler alternative to POI. (The Word package is not quite as mature as the spreadsheet package.)

基本上你生成 html,但是使用 cfheader/cfcontent 来告诉浏览器内容实际上是一个 Word 文档.它显然不是真正的 MS Word 文件.但它比大多数选项更简单.

Basically you generate html, but use cfheader/cfcontent to tell the browser the content is really a Word document. It is obviously not a true MS Word file. But it is simpler than most options.

http://msdn.microsoft.com/en-us/library/aa155477.aspx

<cfheader name="Content-Disposition" value="attachment; filename=someFile.doc">
<cfcontent type="application/msword"> 
... your html code here ...