我试图在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上却没有。当打开文件时,它会说:
Datei 'NiceName.xlsx‘kann von ge ffnet werden,da das Dateiformat Die Dateierweiterungültig ist。berprüfen Sie,ob die Datei besch digt ist und ob die Dateierweiterung dem Dateiformat。
这意味着:
Excel无法打开文件'NiceName.xlsx',因为文件格式或-ending无效。请验证,如果文件已损坏,文件结束是否与文件格式相对应.
我可以:
<cfmailparam>工作表并通过邮件接收文件。<cfspreadsheet action="write">表并在服务器上接收文件。在这两种情况下,文件都是可读的。
我试过:
<cfspreadsheet action="write">的工作表,然后使用<cfcontent file="#pathToFile#">,这是行不通的。<cfabort>,这样其他的事情就不会发生了。但什么都帮不上忙。
我在用:
发布于 2014-12-03 17:32:58
尝试使用application/vnd.ms-excel,而不是openoffice。这将是excel特定的mime类型。使用openoffice的人会自动转换,因为他们用这种方式设置了它。这是我唯一能看到的东西。
https://stackoverflow.com/questions/27277617
复制相似问题