废话不多说,直接上代码吧
复制代码 代码如下:
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');
}
http://www.bkjia.com/phpjc/328158.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/328158.htmltecharticle废话不多说,直接上代码吧 复制代码 代码如下: public function export_data($data = array()) { # code... include_once(app_path.'tools/phpexcel/classes/phpexcel/writ...