Solution for #2501147: Issues with Empty cells
Problem/Motivation
It would be great if a user could choose whether or not $cells->setIteratorOnlyExistingCells was set to TRUE or FALSE in a parameter for phpexcel_import() in phpexcel.inc.
With $cells->setIteratorOnlyExistingCells(TRUE), users are severely limited to the excel sheets they can import.
Take this sheet for example:
key | value | description
aaa | | sfs
| 9.8 | fdg
bbb | 8.1 | kjl
Currently it would be read in a way that it would get output into an array like this:
[0] => Array
(
[key] => aaaa
[value] => sfs
)
[1] => Array
(
[key] => 9.8
[value] => fdg
)
[2] => Array
(
[key] => bbb
[value] => 8.1
[description] => kjl
)
But if the user could set IteratorOnlyExistingCells to false, they could get an output like this:
[0] => Array
(
[key] => aaaa
[value] =>
[description] => sfs
)
[1] => Array
(
[key] =>
[value] => 9.8
[description] => fdg
)
[2] => Array
(
[key] => bbb
[value] => 8.1
[description] => kjl
)
In this case, the second output is ideal.
Proposed resolution
- Add
$iterate_only_existing_cells = TRUE as a parameter to phpexcel_import()
- Change
$cells->setIterateOnlyExistingCells(TRUE) to $cells->setIterateOnlyExistingCells($iterate_only_existing_cells);
- Fix documentation to reflect change
Comments
Comment #1
cbanman commentedThis is how I propose it be done
Comment #2
cbanman commentedComment #3
wadmiraal commentedThis is fixed in the last dev release. Up until now, it was not possible to alter this by calling
setIterateOnlyExistingCells()usinghook_phpexcel_import()($op='row'), as it was set after calling the hook. Now the hook implementations are invoked after settingsetIterateOnlyExistingCells(FALSE), so it is possible to override it like so:Side note: default is
FALSEagain, which reverts the change made in 3.10 (which set it toTRUE).I will publish a new release as soon as #2501147: Issues with Empty cells is fixed.
Comment #5
cbanman commentedOk, sounds great! Thanks for looking into this and fixing it.