Comments (5)
Hi,
As described in the doc, you should not call next()
directly:
foreach ($reader->getSheetIterator() as $sheet) {
foreach ($sheet->getRowIterator() as $row) {
// do stuff with the row
$cells = $row->getCells();
...
}
}
from spout.
the fact is that I want to do a different thing only for the first line (get the index name and position of the column) and then treat the row with the foreach.
there is no way to use next() directly ?
I bypass the problem like this but this isn't a satisfying solution.
$boolIndex = true;
foreach ($rows as $row) {
if ($boolIndex) {
// do thing for the first line
$boolIndex = false;
}
else {
// do thing for the row
}
}
from spout.
(we can continue the discussion here)
foreach ($sheet->getRowIterator() as $rowIndex => $row) {
if ($rowIndex === 0) {
// do something with the first row
} else {
}
}
This is how it should be done
from spout.
(I was not sure if you will see it)
Yes thanks that a better solution.
I see somewhere that next() was available but you remove it, why ? in that sort of case it's still more clean (I think) to do it with the next().
from spout.
next()
is technically still present (see https://github.com/box/spout/blob/master/src/Spout/Reader/XLSX/RowIterator.php#L179-L186). However I don't guarantee that the implementation is 100% compliant with what's expected. I had to do a few hacks to get the streaming part working. I can guarantee that the foreach approach works, but can't for the hasNext/next/current approach
from spout.
Related Issues (20)
- Thanks to package authors! How does it work? HOT 1
- Style not present when editing existing spreadsheet
- It takes around 5 secs to read 1000 rows (25 cols) HOT 1
- This page isn’t working when calling $reader = ReaderEntityFactory:: HOT 1
- Previous issue #861 prematurely closed HOT 4
- Support Excel cell Comments HOT 2
- Unable to open source data
- Trying to add vertical alignment and fix textWrap for XLSXWriter HOT 1
- Add option to change the encoding of the whole exported csv file (not only the content) HOT 1
- PHP 8.1 Error HOT 4
- Incorrect type reported when adding an unsupported type to a cell
- Percentage type reading supported? HOT 1
- Content-Disposition header for file download is not properly encoded HOT 1
- Format date on export XLSX
- Is it possible to use wb instead of wb+ fopen mode in openToFile() in AbstractWriter in order to use compress.zlib:// ? HOT 5
- PHP 8.1 Warnings HOT 2
- Doing cell->getValue() on loop stops when the value is a DateTime Object
- rowIterator->next()
- Count total number of rows for XLSX HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spout.