Last active
March 19, 2019 16:56
-
-
Save mig1098/5de184a0401b9bd0ec37c8d380a31c2f to your computer and use it in GitHub Desktop.
Read data from excel. PHPExcel library
This file contains 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
<?php | |
include('../PHPExcel/PHPExcel/IOFactory.php'); | |
//@param $temp_file path name of file or tmp_name from input file | |
function leerArchivoExcelCsv($temp_file){ | |
$arrayData = array(); | |
$inputFileName = $temp_file; | |
/*check point*/ | |
$inputFileType = PHPExcel_IOFactory::identify($inputFileName); | |
$objReader = PHPExcel_IOFactory::createReader($inputFileType); | |
$objPHPExcel = $objReader->load($inputFileName); | |
$data = array(1,$objPHPExcel->getActiveSheet()->toArray(null,true,true,true)); | |
//mgprint($data); | |
if($data[0]==1){ | |
$ff=1; | |
foreach($data[1] AS $row){ | |
if($ff == 1){ $ff++; continue; }//primera linea son titulos, no se considera | |
$row1 = array(); | |
foreach($row AS $column){ | |
$row1[] = $column; | |
} | |
$arrayData[] = $row1; | |
} | |
} | |
return $arrayData; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment