Skip to content

Instantly share code, notes, and snippets.

@jorisros
Created November 6, 2014 09:30
Show Gist options
  • Select an option

  • Save jorisros/ac83ca2b53e3fe3ed233 to your computer and use it in GitHub Desktop.

Select an option

Save jorisros/ac83ca2b53e3fe3ed233 to your computer and use it in GitHub Desktop.
Example phpexcel read data
//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