我想你的toBinary()和tobase64()可能会受到阻碍。
这是一个使用cfspreadsheet,spreadsheetAddColumn和SpreadsheetAddRows的工作示例。
<!--- FILE --->
<cfset myFile = expandPath('accountslog_#dateFormat(url.datefrom, 'yyyy-mm-dd')#_#dateFormat(dateAdd('d',1,url.dateto), 'yyyy-mm-dd')#.xls') />
<cfset thisSheet = SpreadsheetNew("accountLog") />
<cfquery name="all">
SELECT
accountlog.dateTime
, accounts.firstname
, accounts.lastname
, accounts.email
, ... more columns
FROM accountlog INNER JOIN accounts on accountlog.accountid = accounts.id
WHERE dateTime
BETWEEN <cfqueryparam value="#url.dateFrom#" cfsqltype="cf_sql_timestamp">
AND <cfqueryparam value="#dateAdd('d',1,url.dateTo)#" cfsqltype="cf_sql_timestamp">
<cfif url.accountid neq ''>
AND accounts.id = <cfqueryparam value="#url.accountid#" cfsqltype="cf_sql_varchar">
</cfif>
ORDER BY datetime
</cfquery>
<cfset thisTable = 'accountLog'>
<cfset thisSheet = SpreadsheetNew(thisTable) />
<!--- COLUMN HEADERS, droooool --->
<cfloop array="#all.getMetaData().getColumnLabels()#" index="c">
<cfset spreadsheetAddColumn(thisSheet, c) />
</cfloop>
<!--- ADD THE DATA --->
<cfset SpreadsheetAddRows(thisSheet, all) />
<!--- SAVE THE SHEET --->
<cfspreadsheet
action="update"
filename="#myFile#"
name="thisSheet"
sheetname="#thisTable#" />
<cfheader name="Content-Disposition" value="attachment; filename=#listLast(myFile, '\')#" />
<cfcontent type="application/msexcel" reset="yes" file="#myFile#" deleteFile="yes" />
(编辑)不是讽刺,但你在发布之前是否对该错误消息进行搜索?有很多关于该错误常见原因的线索。通常与Excel安全设置有关。另外,如果这是实际的代码,'cfheader'很害羞,而且头文件中有一个拼写错误。 – Leigh
嗨Leigh ..是的,我在论坛上查看了其他相关的其他问题,但没有找到正确的答案。如果您能看到相关的内容,请将我引导至特定问题,并且您可以自由关闭此主题。我只是需要一个正确的答案,我的真正的问题,没有更多的东西:) – Tej