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

PHP - Session mismatch, different id and wrong user, hijack risk and a major security risk
Weird behavior when trying to compare field to 0 in where clause
Redux Wordpress Framework enqueue style
How do I parse a complicated string to an array using one of those preg_ functions? [closed]
Homepage incorrect in Symfony2 (installation) [closed]
HTTP headers in php, perl and python
PHP display image without HTML
Get value from Objects in an Array Wordpress
Codeigniter 2.2 failed create session
png transparent removed when merge 2 image in php
Failed to open stream: No such file or directory
Crud functionality, Trying to update user details with php and mysql
Drupal : curl call + view file pdf
Doctrine Events best practise?
Q2A: Is there a revert / undo to changes made in Admin through a PHP file?
translate phpmyadmin syntax table.field

Categories

HOME
nam
android-espresso
freeradius
shinyapps
adfs3.0
postgresql-9.4
tcsh
nsview
braintree
apk
mathematical-optimization
firebase-database
phpmqtt
pyresttest
tweepy
heuristics
business-intelligence
cuba-platform
amazon-elb
trace32
mailgun
global-variables
reselect
pinterest
gravity
jest
node-webkit
workday
gollum-wiki
uislider
intel
websphere-portal
sybase-ase
sipp
animated-gif
tracing
introspection
strophe.js
fstar
spreadsheetgear
crud
list-comprehension
android-cardview
annotation-processing
cube
materialize
dotcms
matlab-app-designer
devtools
markov-chains
amazon-kms
grails-2.5
subclassing
redgate
forms-authentication
cloudera-quickstart-vm
widestring
rdp
right-click
zend-form
code-push
destroy
common-table-expression
sonarqube5.2
cyanogenmod
comm
sonatype
case-when
gawk
metabase
msg
data-management
pyaudio
openseadragon
cdo.message
android-4.2-jelly-bean
bbc-micro
unsigned
wicked-pdf
simian
polymerfire
grinder
servicestack-bsd
linuxbrew
opencyc
dsa
dnx50
ocmockito
kotlin-android-extensions
findersync
directorysearcher
uno
smacss
visual-studio-6
xhprof
forio-contour
forceclose
refit
gpu-programming
pre
spring-social-linkedin
progress-db
discovery
quickgraph
postgres-xc
ofstream
tfs-sdk
2d-vector
viewpagerindicator
jdom
platform-independent
wcf-callbacks
acpi
kolite
glx
boost-foreach
play2-mini
space-partitioning
css-friendly
turbine
hungarian-notation
cassini
ccnet-config
3270
parentid

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile