Hi,
We have code that is creating an excel workbook with the POI library and then using CFHeader to set the filename with content-disposition as shown in the code below. After setting the content-disposition,we write the Excel workbook to the browser. The code is below.
This works wonderfully in CF 9 but when we upgraded to CF 11 we found that this is no longer working. The same code works fine in CF 9 but not in CF 11. The filename is being ignored and the file is now being given the name of the cfm script being called with the correct xls extension.
Any suggestions as to what is causing this in CF 11 and not in CF 9 would be appreciated.
Code:
<cfheader name="Content-Disposition" value='attachment; filename="#arguments.fileName#" ' >
<cfscript>
// Write the workbook to the ByteArrayOutputStream to obtain the ContentLength
local.workBook.write(local.outStream);
local.len = arrayLen(local.outStream.toByteArray());
local.outStream.flush();
local.outStream.close();
// Now work on displaying to browser output stream
local.context = getPageContext();
local.context.setFlushOutput(false);
// The getResponse call twice (2nd getResponse) gets the binary response of the character response (1st getResponse)
local.response = local.context.getResponse().getResponse();
// retrieve the output stream of the response to the browser.
local.out = local.response.getOutputStream();
local.response.reset();
//Set the content type and the contentLength
// if both are not provided, then the data will not display correctly
local.response.setContentType("application/vnd.ms-excel");
local.response.setContentLength(local.len);
// write the workbook to the http response binary output stream
local.workBook.write(local.out);
// clean things up and close the output stream
local.out.flush();
local.response.flushBuffer();
local.out.close();
</cfscript>
Regards,
Leslie