0

嗨,我正在下载一个 excel 文件,它显示以下错误

Word cannot open the file because the file format does not match the file extension

我在 CakePHP 中下载 Excel 的代码是

foreach($info as $absentRcrd){
  $empInfo = array('Sl No' => $slNo++,
                    'Employee ID' => $absentRcrd['emp_id'],
                    'Employee Name' => $absentRcrd['employee_name'],
                    'DOJ' => $absentRcrd['doj'],
                    'Departmernt' => $absentRcrd['department_name'],                        
                    'Mobile' => (!empty($empMobile) ? $empMobile : 'NA'),
                    'Email Personal' => (!empty($absentRcrd['email_personal']) ? $absentRcrd['email_personal'] : 'NA'),
                    'Supervisior' => $absentRcrd['supervisor_name'],                        
                    'Supervisior Mobile' => (!empty($supMobile) ? $supMobile : 'NA'),
                    '# Days Absent' => $absentRcrd['days_absent'],
                    'Details' => $absentRcrd['details'],
}

 $rpt['Attachment']['file_type'] = 'application/vnd.ms-excel';          
 $fileName = 'LeavesReport_'.$frmDate.'-'.$toDate.'.xls';
 $rpt['Attachment']['file_name'] = str_replace(' ','_',$fileName);
 $this->set('attachment', $rpt);
4

0 回答 0