gpt4 book ai didi

coldfusion - 服务器生成的word文件: Change default "save as" option to ".doc" instead of "website"

转载 作者:行者123 更新时间:2023-12-04 01:25:17 25 4
gpt4 key购买 nike

我们有一个应用程序,我们在 ColdFusion 服务器上生成一个 .doc 文件。该文件在 MSWord 中正确打开并正确显示。

在 Internet Explorer 中,它询问我是下载还是保存文件。保存时,文件在我的下载文件夹中保存为file.doc,是正确的。

直接从 Internet Explorer 打开时,文件显示正确。但是当我在 MSWord 中“另存为”时,默认文件类型是“网站”而不是“word 文档”。

下面是这个词的内容。我知道有更好的解决方案,但我们当时就是这样做的。

<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'>
<head>
<title>file name goes here</title>
<!--[if gte mso 9]>
<xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:Zoom>90</w:Zoom>
<w:DoNotOptimizeForBrowser/>
</w:WordDocument>
</xml>
<![endif]-->
<style>/*style goes here*/</style>
</head>
<body>body goes here</body>
</html>

我曾尝试添加文档类型,但什么也没发生。

在 ColdFusion 上,会发生以下情况:
<cfcontent reset="true" type="application/vnd.ms-word" />
#wordContent#
<cfheader name="Content-Disposition" value="attachment; filename=file.doc" />

我也试过“application/msword”作为 MIME-Type,但什么也没发生。

我曾尝试将其设为 .docx,但随后它的格式不正确,这似乎合乎逻辑,因为它不是 xml 而是 html。

我希望,可能有一些元信息,它允许我访问默认文件名,例如
<o:Author>Author name goes here</o:Author>
<o:LastAuthor>Last authors name goes here</o:LastAuthor>
<o:Revision>1</o:Revision>
<o:Created>#dateFormat(now(),"yyyy-mm-dd")#T#timeFormat(now(),"HH:mm")#Z</o:Created>
<o:LastSaved>#dateFormat(now(),"yyyy-mm-dd")#T#timeFormat(now(),"HH:mm")#Z</o:LastSaved>
<o:Version>12.00</o:Version>
</o:DocumentProperties>

我还使用了这里提供的信息 http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats

但它们似乎都不起作用。所以我在这里,寻求帮助。

编辑:添加了 MSWord 行为错误的屏幕截图(德语)

saving as gives me the wrong default file type

最佳答案

老实说,我认为无法更改默认的“另存为类型”值。虽然您可以使用 MS Word 欺骗浏览器打开内容,但 Word 仍然足够智能以识别当前内容是 HTML。因此它相应地设置了默认文件类型。

无论如何,您仍然可以选择.doc手动输入文件类型。但是,只要您生成的仿 MS Word 文件(即 HTML)就可能是最好的。

关于coldfusion - 服务器生成的word文件: Change default "save as" option to ".doc" instead of "website",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16835824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com