excel - 冷融合11 : CFContent doesn't write openable excel file

标签 excel iis coldfusion cfspreadsheet coldfusion-11

我正在尝试在 ColdFusion 中执行一项简单的任务:生成一个 excel 文件并将其下载到浏览器中。我有这个:

<cfset local.sheet = SpreadsheetNew("My Spreadsheet", "true") />
<cfset SpreadsheetAddRow(local.sheet, "Col1,Col2,Col3") />

<cfheader name="content-disposition" value="attachment;filename=NiceName.xlsx" />
<cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" variable="#spreadsheetReadBinary(local.sheet)#" reset="true" />

这在 CF9 上运行得很好,但在 CF11 上却不行。打开文件时,它显示:

日期“NiceName.xlsx”可以在 Excel 中使用,因为日期格式或日期格式不正确。 Überprüfen Sie,ob die i beschädigt ist und ob dieerweiterung dem Dateiformat entspricht。

这可以翻译为:

Excel 无法打开文件“NiceName.xlsx”,因为文件格式或结尾无效。请验证文件是否损坏以及文件结尾是否与文件格式相对应。

<小时/>

我可以:

  • <cfmailparam>表格并通过邮件接收文件。
  • <cfspreadsheet action="write">工作表并在服务器上接收文件。

在这两种情况下,文件都是可读的。

<小时/>

我已经尝试过:

  • <cfspreadsheet action="write">工作表,然后使用 <cfcontent file="#pathToFile#"> ,这不起作用。
  • 检查了我的 IIS 的 URL 重写规则。
  • 检查了我的 IIS 中的 .xlsx MIME 类型。这与我的代码中的相同。
  • 添加了<cfabort>最后,所以不会发生任何其他事情。

但没有任何帮助。

<小时/>

我正在使用:

  • ColdFusion 11 (11,0,0,289974) 与 Tomcat 7.0.52.0
  • Windows Server 2008 R2 标准版 64 位
  • 微软 Office 2013
  • IIS 7.5.7600.16385

最佳答案

尝试使用 application/vnd.ms-excel 而不是 openoffice 品种。这将是 Excel 特定的 mime 类型。使用 openoffice 的人会自动转换,因为他们已经这样设置了。这是我在这里看到的唯一东西。

关于excel - 冷融合11 : CFContent doesn't write openable excel file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27277617/

相关文章:

excel - VBA如果单元格小于一定长度,突出显示并显示消息

web-services - 如何将 Web 服务从 Visual Studio 发布到 IIS?

coldfusion - 元素在类型为 coldfusion.runtime.J2eeSessionScope 的 Java 对象中未定义

javascript - 将网址从 'https' 替换为 'http' ,我的网址无限刷新

excel - Excel VBA 使用 Telegram bot api 发送图像

excel - 为什么单击 Excel/Word 中的链接似乎会导致我的非 IE 浏览器伪装成 MSIE 7.0?

asp.net - HTTP 错误 500.19 - 内部服务器错误?

虚拟目录中的 IIS 配置文件

coldfusion - 如何从 ColdFusion 中的文件夹下载所有附件

Excel - 从列表中查找下一个大于 0 的值