我的代码完全适用于Chrome和IE,但当我尝试使用Firefox下载文件时,它没有扩展名。我已经尝试过在stackoverflow中给出的不同解决方案与我的相同问题,但没有任何作用。有没有人可以帮我这个?
这是我的PHP代码:
function empsal_to_excel(){
$empsal = $_SESSION['empsalParam'];
$rows = $this->SalaryReport->getBranchSalary($empsal['branch']);
$numrows = count($rows);
// Send Header
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");;
header("Content-Disposition: attachment;filename=Employee Salary Report:".$_SESSION['comp_name'].".xls "); // à¹à¸¥à¹‰à¸§à¸™à¸µà¹ˆà¸à¹‡à¸Šà¸·à¹ˆà¸à¹„ฟล์
header("Content-Transfer-Encoding: binary ");
// XLS Data Cell
$this->xlsBOF();
$this->xlsWriteLabel(1,3,$_SESSION['comp_name']);
$this->xlsWriteLabel(4,0,"REPORT TITLE : ");
$this->xlsWriteLabel(4,1,"Employee Salary Report");
$this->xlsWriteLabel(4,6,"REPORT PRINT DATE : ");
$this->xlsWriteLabel(4,7, date('Y-m-d'));
$this->xlsWriteLabel(7,0,"EMPLOYEE NO.");
$this->xlsWriteLabel(7,1,"EMPLOYEE NAME");
$this->xlsWriteLabel(7,2,"JOB DESCRIPTION");
$this->xlsWriteLabel(7,3,"DEPARTMENT");
$this->xlsWriteLabel(7,4,"BRANCH");
$this->xlsWriteLabel(7,5,"SHIFTING SCHEDULE");
$this->xlsWriteLabel(7,6,"SALARY FREQUENCY");
$this->xlsWriteLabel(7,7,"SALARY");
$xlsRow = 9;
$t=0;
$to_log=array();
while($t<$numrows){
$y=0;
foreach($rows[$t] as $key=>$items){
$to_log[]=$key."=>".$items;
$this->xlsWriteLabel($xlsRow,$y,$items);
$y++;
}
$xlsRow++;
$t++;
}
$this->xlsEOF();
$this->_audittrailbase->_log('EXPORT_TO_EXCEL', 'Report' ,$to_log,null,$_SESSION['branch']);
exit();
}
function xlsBOF() {
echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
//return;
}
function xlsEOF() {
echo pack("ss", 0x0A, 0x00);
// return;
}
function xlsWriteNumber($Row, $Col, $Value) {
echo pack("sssss", 0x203, 14, $Row, $Col, 0x0);
echo pack("d", $Value);
//return;
}
function xlsWriteLabel($Row, $Col, $Value ) {
$L = strlen($Value);
echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L);
echo $Value;
//return;
}