I find it difficult to export a report. Basically, a button is clicked and a report is created on the server side using the following javascript: -
__callExportController(true, { op: 'build', type: exportType }, function(data) {
var outputURL = './reportinc/export_controller.php?op=output&filename=';
var reportFilename = data['filename'];
var reportTitle = data['title'];
if (reportFilename && reportTitle) {
var resultURL = outputURL + reportFilename + '&title=' + reportTitle;
if (!$('#exportFrame').length) {
var hiddenIFrame = document.createElement('iframe');
hiddenIFrame.setAttribute('id','exportFrame');
document.body.appendChild(hiddenIFrame);
}
$('#exportFrame').attr('src', resultURL);
} else {
error('No filename or report title specified!');
}
});
The build operation of the export controller creates a report in a temporary file on the server. If this succeeds, the "output" operation is called to output this file to a hidden iframe to receive a download prompt to the user. Internet Explorer 6/7 are the only browsers used here.
This is the output handler on the server that the iframe will request with a successfully created file name: -
case 'output':{
$filename = $_GET['filename'];
header('Content-Description: File Transfer');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Type: application/pdf");
header("Cache-Control: private");
header("Pragma: cache");
header("Content-Disposition: attachment; filename=\"file.pdf\"");
header('Content-Length: ' . filesize($filename));
ob_clean();
flush();
readfile($filename);
@unlink($filename);
}
, , : , , , . , , , , . " ", .
, , , , .
- ? -, ?