Home  >  Article  >  Backend Development  >  YIIframe 上excel文件的下传,读取数据保存进数据库?如何做啊求。

YIIframe 上excel文件的下传,读取数据保存进数据库?如何做啊求。

WBOY
WBOYOriginal
2016-06-13 11:15:20893browse

YIIframe 下excel文件的上传,读取数据保存进数据库?怎么做啊?急求。。。
急求啊,小弟对这个框架不熟悉,好多都不会。。。。

excel 数据库 php?yii
------解决方案--------------------
phpexcel
phpexcel
设计好数据库用phpexcel读取后插入就可以了。具体的看phpexcel documentation
------解决方案--------------------
1.下载phpexcel
 
2.解压到/protected/extesions/phpexcel
 
3.调用
	public function actionExcel(){<br />		$excel_path = dirname(__FILE__) . '/../../files/users.xlsx';<br />		Yii::import('ext.phpexcel.Classes.*');<br /><br />		//关闭yii的自动装载<br />		spl_autoload_unregister(array('YiiBase','autoload'));<br /><br />		include 'PHPExcel/IOFactory.php';<br />		<br />		$objPHPExcel = PHPExcel_IOFactory::load($excel_path);<br />		$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);<br />		var_dump($sheetData);<br /><br />		//恢复yii的自动装载<br />		spl_autoload_register(array('YiiBase','autoload'));<br />		<br />	}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn