php


Parsing file Excel from PHP


I have a function PHP to parse file Excel, it read all the number of the rows but it doesn't return all the data in the object.
Number of lines 3247, but it return just 1023 lines.
this following the parsing function:
public function parseEquipement($filePath = null) {
set_time_limit(0);
$listEquipement = [];
$count = 0;
$chunkSize = 8192;
$objReader = PHPExcel_IOFactory::createReader(PHPExcel_IOFactory::identify($filePath));
$spreadsheetInfo = $objReader->listWorksheetInfo($filePath);
$chunkFilter = new \Floose\Parse\ChunkReadFilter();
$objReader->setReadFilter($chunkFilter);
$objReader->setReadDataOnly(true);
$chunkFilter->setRows(0, 1);
$objPHPExcel = $objReader->load($filePath);
$totalRows = $spreadsheetInfo[0]['totalRows'];
for ($startRow = 1; $startRow <= $totalRows; $startRow += $chunkSize) {
$chunkFilter->setRows($startRow, $chunkSize);
$objPHPExcel = $objReader->load($filePath);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null, null, true, false);
$startIndex = ($startRow == 1) ? $startRow : $startRow - 1;
if (!empty($sheetData) && $startRow < $totalRows) {
$dataToAnalyse = array_slice($sheetData, $startIndex, $chunkSize);
if($dataToAnalyse[0][0]==NULL){
break;
}
for ($i = 0; $i < $chunkSize; $i++) {
if ($dataToAnalyse[$i]['0'] != NULL) {
$listEquipement[] = new Article($dataToAnalyse[$i]['0'], '', $dataToAnalyse[$i]['1']);
$count++;
}
}
}
//echo($totalRows); // is best
//echo($count); // is wrong
//print_r($listEquipement);
$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel, $sheetData);
}
return $listEquipement;
}
I changed all the code by this following but it doesn't work:
public function parseEquipment($filePath = null) {
$objReader = PHPExcel_IOFactory::createReader(PHPExcel_IOFactory::identify($filePath));
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($filePath);
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
for ($row = 2; $row <= $highestRow; $row++){
echo $sheet->getCellByColumnAndRow(3, $row)->getCalculatedValue();
echo $sheet->getCellByColumnAndRow(4, $row)->getCalculatedValue();
echo $sheet->getCellByColumnAndRow(2,$row)->getCalculatedValue();
$listEquipement[] = new Article(
$sheet->getCellByColumnAndRow(3, $row)->getCalculatedValue(),
$sheet->getCellByColumnAndRow(4, $row)->getCalculatedValue(),
$sheet->getCellByColumnAndRow(2, $row)->getCalculatedValue()
);
}
}
And when I run my code always it display an error of memory size knowing that the size of my file is 81K and it display the number of lines in the same time.
Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (Tried to allocate 54byte)
Could anyone be kind enough to guide and teach me how I should do my codes or can you suggest me another code to parsing a file Excel ?

Related Links

How to add model variable to another model in Laravel
Wordpress theme mods api and update
How do you enable multithreading on nginx and apache
How to sort an array from linear distribution to normal distribution in PHP?
How to convert a PHP DOMElement into a PHP DOMNodeList
Why i cannot set my db table with a code one by one in php?
how to pass custom fields to $_POST or $_GET in CKEdtior Upload dialog?
Access local parameters from module services and controllers
define to_date symfony2 doctrine
if(isset($_POST['Submit'])){} Not working
How can I make my radio checkbox's only be allowed one check per row in my table
filesmatch htaccess convert to nginx (on plesk)
Fetching orders details throught flipkart api using PHP(how to recall function without rewrite function declaration)
how base64 converts characters that aren't existing in its character list?
How to read data from XML file using php
How can I limit the parameters of the GET values to the ones in my array?

Categories

HOME
shinyapps
selenium-builder
elisp
supercollider
angular-meteor
sap-fiori
pm2
live-streaming
outlook-restapi
smartgwt
bundler
bnf
uima
jaspersoft-studio
amazon-mws
jest
sqlplus
stackexchange.redis
generator
software-packaging
vuforia
mod-wsgi
plyr
math.js
materialize
steam-web-api
serversocket
grails-2.5
assertions
cartopy
sbjson
task-parallel-library
coverage.py
1wire
httphandler
ssi
nonlinear-functions
google-news
mongodb-aggregation
portability
predicates
perl-data-structures
portal
cefpython
bigdecimal
svnserve
node.js-connect
powerpoint-2013
processor
jemdoc
swiffy
gravatar
voronoi
chicagoboss
astropy
dnx50
supersocket.net
swagger-maven-plugin
actionpack
fat32
dos2unix
adhoc-polymorphism
encryption-symmetric
cakephp-2.2
device-admin
qt5.4
quantify
webmethod
jini
neo4jphp
usb-flash-drive
spring-security-acl
yii-booster
rikulo
spiral
donut-chart
lynx
cgrectmake
onconfigurationchanged
instance-variables
system-information
nsfont
uploading
n-queens
qtextbrowser
drawimage
glassfish-esb
cassini
zend-test
powergui
.net-client-profile
account-management

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App