集成PHPExcel

阅读更多

1.下载phpexcel

 

2.解压到/protected/extesions/phpexcel

 

3.调用

	public function actionExcel(){
		$excel_path = dirname(__FILE__) . '/../../files/users.xlsx';
		Yii::import('ext.phpexcel.Classes.*');

		//关闭yii的自动装载
		spl_autoload_unregister(array('YiiBase','autoload'));

		include 'PHPExcel/IOFactory.php';
		
		$objPHPExcel = PHPExcel_IOFactory::load($excel_path);
		$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
		var_dump($sheetData);

		//恢复yii的自动装载
		spl_autoload_register(array('YiiBase','autoload'));
		
	}
 

你可能感兴趣的:(集成PHPExcel)