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

Confirming Markdown Files
PHP SimpleXMLElement XPath Selection
PHP Unexpected T_encapsed [closed]
How to echo this specific value from a Database
Embedding a php function within a php form template variable
Yii - PHP error after content saying that LogDetailFilter couldn’t be found
mysql query , gives me wrong number of rows am after
How do I include a range of lines of a file in php?
How to display and manipulate visual objects in a web app?
Please help me with my comment sections sql query
How to extract data from this JSON ? [closed]
Image cropping and thumb creation
How to draw a name in a database [duplicate]
PHP: Generating category/subcategory UL list from array?
wikipedia servers gzip content
How to escape ' in setParameter

Categories

HOME
xpath
mc
yii
adfs3.0
key
swi-prolog
activemq
apk
celery
mirc
lvm
vue-resource
elk-stack
tibco
azure-data-lake
ui-automation
minecraft
tfs2010
eddystone
elastic-load-balancer
yeoman-generator-angular
angular4
google-awareness
pygobject
cocos2d-android
node-webkit
uislider
generator
ini
software-packaging
firemonkey-style
web-push
beego
msdeploy
tf-idf
math.js
bobo-browse.net
materialize
unmarshalling
tilemill
xenapp
wampsharp
rspec-rails
gsp
advanced-filter
android-canvas
rails-postgresql
subclassing
jade4j
nanogallery
llvm-ir
robust
elasticsearch-aggregation
nomad
vesta
axis
nonlinear-functions
hibernate-ogm
sigsegv
skip-lists
predicates
wildfly-9
mathjs
dcount
android-4.2-jelly-bean
perforce-integrate
node.js-connect
mathnet
polymerfire
helm
in-app-billing
msgpack
html.actionlink
gql
green-threads
dynamics-ax-2012-r2
karma-coverage
mojo
git-reset
forio-contour
map
windows-taskbar
vlab
notifyjs
mp4parser
node.js-stream
jquery-lazyload
daap
opends
net-use
representation
odac
android-input-method
facebook-fbml
gtktextview
gui-designer

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