1

'excelFileQuery' contains a query.

<cfset spreadsheetAddRows(s, excelFileQuery)>
<cfset spreadsheetAddRows(s,"#volunteeralias# Export Report (#dateformat(now(),'mmmm d, yyyy')# at #timeformat(now(),'h:mm tt')#)",1,1)>
<cfheader name="content-disposition" value="attachment; filename=myexcel.xlsx">
<cfcontent type="application/msexcel" variable="#spreadsheetReadBinary(s)#" reset="true">

But when the file is generated, on the query rows are showing up, not the second row. Am I doing it wrong?

4

1 回答 1

7

我不太确定您的目标,但spreadSheetAddRows需要一个查询或一个数组。所以第二条语句应该传入一个数组,而不是字符串。如果您更喜欢使用字符串,则必须改用电子表格SetCellValue函数。

如果您的目标是在查询结果之后附加最后一个字符串,请先将该字符串转换为数组。此外,删除行/列号,以便将数据附加到查询结果之后的第一个空行。

<cfset spreadsheetAddRows(s, excelFileQuery)>
<cfset spreadsheetAddRows(s, ["#volunteeralias# Export Report (#dateformat(now(),'mmmm d, yyyy')# at #timeformat(now(),'h:mm tt')#)"] )>
...

如果你想把它放在前面(作为标题),做同样的事情,但显然你交换了两个语句。

于 2014-02-24T13:27:05.220 回答