php实现利用phpexcel导出数据
复制代码 代码如下:
public function export_data($data = array())
{
# code...
include_once(APP_PATH.'Tools/PHPExcel/Classes/PHPExcel/Writer/IWriter.php') ;
include_once(APP_PATH.'Tools/PHPExcel/Classes/PHPExcel/Writer/Excel5.php') ;
include_once(APP_PATH.'Tools/PHPExcel/Classes/PHPExcel.php') ;
include_once(APP_PATH.'Tools/PHPExcel/Classes/PHPExcel/IOFactory.php') ;
$obj_phpexcel = new PHPExcel();
$obj_phpexcel->getActiveSheet()->setCellValue('a1','Key');
$obj_phpexcel->getActiveSheet()->setCellValue('b1','Value');
if($data){
$i =2;
foreach ($data as $key => $value) {
# code...
$obj_phpexcel->getActiveSheet()->setCellValue('a'.$i,$value);
$i++;
}
}
$obj_Writer = PHPExcel_IOFactory::createWriter($obj_phpexcel,'Excel5');
$filename = "outexcel.xls";
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-Disposition:inline;filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary");
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");
$obj_Writer->save('php://output');
}
上一篇: iis 301重定向 eurl.axd,该如何解决
下一篇: thinkphp解决方法
推荐阅读
-
php将数据库导出成excel的方法_PHP教程
-
PHP实现域名whois查询 数据源万网、新网_PHP
-
dragon boat festival php实现post接口 接收android客户端json数据 存储数据库 并返回json
-
php+mysql数据库实现无限分类的方法
-
PHP将Excel导入数据库及数据库数据导出至Excel的方法,excel数据导出_PHP教程
-
php实例-php实现查询功能(数据访问)
-
PHP 实现多服务器共享 SESSION 数据
-
php把数据表导出为Excel表的最简单、最快的方法(不用插件)
-
php怎么实现前台数据自动更新
-
php利用正则表达式实现手机号码格式验证代码