I used Yii to build a background, in the background page to add the Export button click the Export button is to export the current page data to a table how to do this function?? Before that, I tried using phpexcel to export the example with Phpexcel, but I threw the exported method to the controller, and when I called it with Index.php?r=tips/excel, I showed Notfount
Reply to discussion (solution)
1. Put the phpexcel inside the extension.
2.main.php introduced ' extensions. Phpexcel.classes.* ';
3. Write your own export code
4.1-2 not, I can not help you, 3 not, just refer to the Phpexcel example
Below I give an example of my own writing, I am directly importing an Excel class that you can load when the component is loaded. Look at a person's liking
Yii::import (' application.extensions.phpexcel.classes.* '); $objPHPExcel = new Phpexcel (); $objPHPExcel->getproperties ()->setcreator ("Maarten Balliauw")->setlastmodifiedby ("Maarten Balliauw") ->settitle ("Office" xlsx Test Document ")->setsubject (" Office "xlsx Test Document") ->setdescription ("Test document for Office" XLSX, generated using PHP classes. ") ->setkeywords ("Office openxml PHP")->setcategory ("Test result file"); $objPHPExcel->getactivesheet ()->settitle (' name '); $objPHPExcel->setactivesheetindex (0); $objWriter = new Phpexcel_writer_excel5 ($objPHPExcel); Header ("Pragma:public"); Header ("expires:0"); Header (' Content-type:application/vnd.ms-excel;charset=utf8 '); Header ("Cache-control:must-revalidate, Post-check=0, pre-check=0"); Header ("Content-type:application/force-download"); Header"Content-type:application/vnd.ms-execl"); Header ("Content-type:application/octet-stream"); Header ("Content-type:application/download"); $fireName = ' counting order '; Header ("Content-disposition:attachment;filename= $fireName. xls"); Header ("Content-transfer-encoding:binary"); $objWriter->save ("Php://output"); Yii::app ()->end (); Spl_autoload_register (Array (' yiibase ', ' autoload ')); }//long-term data export private function Defaulta ($objPHPExcel, $resource) {$objPHPExcel->setactivesheetindex (0) ->setcellvalue (' A1 ', ' Order ID ')->setcellvalue (' B1 ', ' Order sn ') $i = 2; foreach ($resource as $row) {$objPHPExcel->setactivesheetindex (0)->setcellvalue ("A$i", $r ow[' order_id ')->setcellvalue ("B$i", "$row [ORDER_SN]"); $i + +; } }