No more nonsense, just go to the code.
Copy CodeThe code is as follows:
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.html www.bkjia.com true http://www.bkjia.com/PHPjc/328158.html techarticle no more nonsense, just on the code. Copy the code as follows: Public function export_data ($data = Array ()) {# code ... include_once (app_path. ' Tools/phpexce L/classes/phpexcel/writ ...