Forked from jorisros/gist:ac83ca2b53e3fe3ed233
Last active
September 12, 2016 12:17
-
-
Save remoharsono/1dac06d4753ed776e84841abe4a3b578 to your computer and use it in GitHub Desktop.
Example PHPExcel read data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //var_dump(); | |
| require_once(sfConfig::get('sf_root_dir').'/vendor/phpexcel/PHPExcel.php'); | |
| //$php\ | |
| $values = $this->getValues(); | |
| $id = uniqid(); | |
| $file = sfConfig::get('sf_root_dir').'/data/upload/'.$id.'.xlsx'; | |
| move_uploaded_file($values['file']->getTempName(), $file); | |
| $objPHPExcel = PHPExcel_IOFactory::load($file); | |
| $lastRowNumber = (int)$objPHPExcel->getActiveSheet()->getHighestRow(); | |
| $sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); | |
| $formData = $this->getValues(); | |
| $arrProductTitle = explode('-',$formData['range_normal_products']); | |
| // $arrActionColumns = explode('-',$formData['range_action_products']); | |
| $arrProducts = array(); | |
| // $actionColumn = $arrActionColumns[0]; | |
| for($i=$arrProductTitle[0]; $i <= $arrProductTitle[1]; $i++) | |
| { | |
| //var_dump($i); | |
| //var_dump($sheetData[$formData['row_title_products']][$i]); | |
| $arrProducts[$i]['label'] = $sheetData[$formData['row_title_products']][$i]; | |
| // $arrProducts[$i]['action_column'] = $actionColumn; | |
| // $actionColumn++; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment