生成Excel文件,但它不显示正确的文本。它以加密形式显示文本

时间:2015-03-19 09:19:05

标签: php codeigniter phpexcel

当我从我的codeigniter代码生成excel文件时,它不会显示正确的文本。它以加密形式显示文本。 请帮我: 我的代码就像:

$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0)
    ->setCellValue('A1', 'Id')
    ->setCellValue('B1', 'Name')
    ->setCellValue('C1', 'Email')
    ->setCellValue('D1', 'Number')
    ->setCellValue('E1', 'Message');

$filename='report.xlsx'; //save our workbook as this file name
header('Content-Type: application/vnd.ms-excel'); //mime type
header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
header('Cache-Control: max-age=0'); //no cache

//save it to Excel5 format (excel 2003 .XLS file), change this to 'Excel2007' (and adjust the filename extension, also the header mime type)
//if you want to save it as .XLSX Excel 2007 format
//$objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5');  
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');

0 个答案:

没有答案