<cfscript>
// We need an absolute path, use the wheels file path as the base and the filename variable set in the controller.
variables.theFile = "#ExpandPath(application.wheels.filePath)#\reports\#variables.filename#";
// Create a new Excel spreadsheet object and add the header and query data.
variables.theSheet = SpreadsheetNew("YearEndReport");
// Header row
SpreadSheetAddRow(variables.theSheet, "Student Name, Total Cost, Total Payed, New Balance, Total Hours");
// Query data
SpreadSheetAddRows(variables.theSheet, variables.data);
// Formatting of cells
SpreadSheetFormatColumns(variables.theSheet, {dataformat="$##,####0.00"}, "2-4");
SpreadSheetFormatRow(variables.theSheet, {font="serif",fontsize=11,color="black",bold=true,alignment="center",fgcolor="pale_blue",fillpattern="solid_foreground"}, 1);
SpreadSheetSetColumnWidth(variables.theSheet, 1, 25);
SpreadSheetSetColumnWidth(variables.theSheet, 2, 15);
SpreadSheetSetColumnWidth(variables.theSheet, 3, 15);
SpreadSheetSetColumnWidth(variables.theSheet, 4, 15);
SpreadSheetSetColumnWidth(variables.theSheet, 5, 14);
</cfscript>
<!--- Write the spreadsheet to a file, replacing any existing file. --->
<cfspreadsheet action="write" filename="#variables.theFile#" name="variables.theSheet" sheet=1 sheetname="Report" overwrite=true>
<!--- Open Spreadsheet File --->
<cfheader name="Content-Disposition" value="inline; filename=#variables.filename#">
<cfcontent type="application/csv" file="#variables.theFile#" deletefile="no">