|
|
Thanks everyone, I made it work. Special thanks to Adam for the final hint.
:beer;
I'm sure there are more elegant ways but here it is so far...
First I added a script in the <head></head> to call a true window.open()
method:
<head>
<script type="text/javascript">
var displayFile = function() {
var display = '/myPath/to/cfContentDisplay.cfm';
window.open(display,'FileDisplayWin',myOptions);
}
</script>
</head>
Before I call that script I resubmit the query to reflect any changes the user
has made and save the results into a Session variable.
file_display.cfm
...does the query and I place the results in an HTML table and use
CFSAVECONTENT to set a session variable.
<cflock timeout="6" throwontimeout="no" type="exclusive" scope="session">
<cfsavecontent variable="session.displayMyFile">
<cfoutput>
<table cols="5" border="1">
<tr>
<th>SID</th>
<th>Name</th>
<th>School_Year</th>
<th>Stopout?</th>
<th>Email</th>
<th>Last_reminder</th>
</tr>
</cfoutput><cfoutput query="qryShowList">
<cfset lastReminder = IIf(not sent_reminder is "1900-01-01
00:00:00",DE(sent_reminder),DE("Never"))>
<tr>
<td>#person_id#</td>
<td>#first_name# #last_name#</td>
<td>#School_Year#</td>
<td>#yesNoFormat(isStopout)#</td>
<td>#email#</td>
<td><cfif isDate(lastReminder)>
#dateFormat(lastReminder,'DDD, MMM d')# at
#timeFormat(lastReminder,'h:mm tt')#
<cfelse>
#lastReminder#
</cfif></td>
</tr>
</cfoutput> <cfoutput>
</table>
</cfoutput>
</cfsavecontent>
</cflock>
cfContentDisplay.cfm
...is basically copied from the CFCONTENT documentation:
<cfsetting enablecfoutputonly="yes">
<!--- set content type --->
<cfcontent type="application/msexcel">
<!--- suggest default name for XLS file --->
<cfset theTimeRightNow = dateFormat(now(),'YYYY-MM-DD') & "_" &
timeFormat(now(),"h-mm_tt")>
<cfset suggName = dateFormat(now(),'YYYY-MM-DD') & "_" &
timeFormat(now(),"h-mm_tt")&".xls">
<!--- use "Content-Disposition" in cfheader for Internet Explorer --->
<cfheader name="Content-Disposition" value="filename=#suggName#"><cfoutput>
#session.displayMyFile#</cfoutput>
My form button onClick now submits the form using
ColdFusion.Ajax.submitForm(), then calls the popup function, and finally
"return false;" prevents the results from coming back in the div that contains
the button:
<cfinput name="asExcelBtn" type="image" src="./images/asExcelButton.png"
value="Show in Excel"
onclick="ColdFusion.Ajax.submitForm(sendIncompletesForm,'./pathTo/file_display.c
fm');displayFile();return false;">
|
|