标签:style blog color os io 文件 数据 for
解压压缩包里的Classes文件夹中的内容到application\libraries\目录下,目录结构如下:
--application\libraries\PHPExcel.php
--application\libraries\PHPExcel(文件夹)
修改application\libraries\PHPExcel\IOFactory.php文件
--将其类名从PHPExcel_IOFactory改为IOFactory,遵从CI类命名规则。
--将其构造函数改为public
$this->load->library(‘PHPExcel‘); $this->load->library(‘PHPExcel/IOFactory‘); $resultPHPExcel = new PHPExcel(); $resultPHPExcel->getActiveSheet()->setCellValue(‘A1‘, ‘项目‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘B1‘, ‘结果‘); $resultPHPExcel->getActiveSheet()->setCellValue(‘C1‘, ‘数量‘); $i = 2; foreach($m_data[‘jc_fia‘] as $key){ $resultPHPExcel->getActiveSheet()->setCellValue(‘A‘ . $i, $key[0]); $resultPHPExcel->getActiveSheet()->setCellValue(‘B‘ . $i, $key[1]); $resultPHPExcel->getActiveSheet()->setCellValue(‘C‘ . $i, $key[0]); $i ++; } $outputFileName = "123.xls"; $xlsWriter = new PHPExcel_Writer_Excel5($resultPHPExcel); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header(‘Content-Disposition:inline;filename="‘.$outputFileName.‘"‘); header("Content-Transfer-Encoding: binary"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: no-cache"); $xlsWriter->save( "php://output" );
CodeIgniterCodeigniter+PHPExcel导出数据到Excel文件,布布扣,bubuko.com
CodeIgniterCodeigniter+PHPExcel导出数据到Excel文件
标签:style blog color os io 文件 数据 for
原文地址:http://www.cnblogs.com/whlives/p/3910781.html