------------------------------------------------------------------------------------
/** * Phpexcel Data import method * document:https://github.com/phpoffice/phpexcel/blob/develop/documentation/markdown/ Overview/07-accessing-cells.md
* @param string $file file name
* @return msg success:1, FALSE: $msg * @author chenwei.ws*/include'./phpexcel.php ';include'./phpexcel/iofactory.php ';functionExcelreader ($file) { if(@fopen($file, ' R ')) { $objReader= Phpexcel_iofactory::createreader (' Excel2007 '); if( !$objReader->canread ($file)) { $objReader= Phpexcel_iofactory::createreader (' Excel5 '); if( !$objReader->canread ($file)) { die(' supports only. xls type of File! ‘); } } $objReader->setreaddataonly (true); $objPHPExcel=$objReader->load ($file); $objWorksheet=$objPHPExcel-Getactivesheet (); $highestRow=$objWorksheet->gethighestrow ();//Ten $highestColumn=$objWorksheet->gethighestcolumn ();//C $betten= ' A2: '.$highestColumn.$highestRow; $dataArray=$objWorksheet-Rangetoarray ($betten, ‘‘,TRUE,TRUE ); if($dataArray&&Is_array($dataArray)) { foreach($dataArray as $v) { if(intval($v[0]) = = 0) { die(' The data is not in the correct format! ‘); } //Your code here ...
$msg = 1; } } Else { $msg= ' file has no data '; } } Else { $msg= ' file does not exist! '; }
return $msg; }
The above method can be adapted to various occasions and more applications welcome communication.
Link:http://www.cnblogs.com/farwish/p/4279212.html
@ Black eyed poet <www.Chenwei.ws>
[PHP] Phpoffice/phpexcel Data Import method