Created
September 9, 2014 15:53
-
-
Save SuryaElite/462bad9b4377535e4e76 to your computer and use it in GitHub Desktop.
Convert XLSX or XLS file to Array in PHP
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
<?php | |
function convertXLStoArray($infile, $outfile){ | |
if(!file_exists($infile) || !is_readable($infile) || !file_exists($outfile) || !is_readable($outfile)) | |
return FALSE; | |
$fileType = PHPExcel_IOFactory::identify($infile); | |
$objReader = PHPExcel_IOFactory::createReader($fileType); | |
$objReader->setReadDataOnly(true); | |
$objPHPExcel = $objReader->load($infile); | |
echo $objPHPExcel->getSheetCount(),' worksheet',(($objPHPExcel->getSheetCount() == 1) ? '' : 's'),' loaded<br /><br />'; | |
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { | |
$arrayData[$worksheet->getTitle()] = $worksheet->toArray(); | |
} | |
var_dump($arrayData); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
please given my a example for use function