Word无法打开文件,因为文件格式与文件扩展名不匹配

时间:2013-07-18 16:27:33

标签: cakephp

您好我正在下载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);

0 个答案:

没有答案