I have following rows in excel (first row is the header)

key | value | description
aaa |       | sfs
    |  9.8  | fdg

When I the read the excel and print it

$result = phpexcel_import($file_path);
watchdog("Result:", print_r($result, TRUE));

I get the following result. You can see when columns are empty it produces strange result. The headers are mapped with wrong values. How to avoid this?

[0] => Array
                (
                    [key] => aaaa
                    [value] => sfs
                )

[1] => Array
                (
                    [key] => 9.8
                    [value] => fdg
                )

Comments

rroblik’s picture

Same for me.

To come back like the previous release (phpexcel 7.x-3.9) change (line 428, phpexcel.inc)
$cells->setIterateOnlyExistingCells(TRUE);
by
$cells->setIterateOnlyExistingCells(FALSE);

I think this behavior should be controlled by user with a new parameter for the function phpexcel_import (with a default value)

Regards

adhisugha’s picture

Thank you. let me try.

parasolx’s picture

tips #1 solve my problem also. i agree this part should be controlled by user through new parameter instead make it compulsory in module.

cbanman’s picture

#1 also helped me. And I agree too that it should be added as a new parameter.

BartGysens’s picture

An update which slipped in without noticing through GitHub... Naughty programmers ;-) but this fix worked also for me - THX!

cbanman’s picture

Yeah, it's a pretty big change to make without really saying much about it. I added an issue to this module with my proposed solution a few weeks ago #2508650: Add parameter to phpexcel_import to modify $cells->setIterateOnlyExistingCells.

drupalmani28’s picture

#1 solved the problem. Thanks

drupalmani28’s picture

Status: Active » Fixed
rroblik’s picture

Status: Fixed » Needs work

@manikandan.btech I'm not sure this is a fixed issue (no new release since may ...) isn't it ?
@cbanman you should link this issue in your ticket :)

cbanman’s picture

@rroblik good idea. I went ahead and linked it.

Yeah, unfortunately because this module seems to be very minimally maintained, it may take a while for a fix to be implemented.

wadmiraal’s picture

Hi all, thanks for the report and comments. I've been very busy lately, haven't had time to look into this. Sorry for not getting back, though.

I fixed the following in 3.10, which causes the reported issue: #2243117: Load only certain sheets and preserve column index for sparse sheets

Like said in #1, downgrade to 3.9 for now. Let me update the test suite so I can have a regression test and reproduce it, and then I'll fix and roll a new release (current tests all pass; I never make a new release without running them).

I'll keep you posted.

cbanman’s picture

Awesome, thanks for the update.

  • 47c7561 committed on 7.x-3.x
    Issue #2501147: Add regression test for importing Excel files with empty...
wadmiraal’s picture

Status: Needs work » Fixed

Fixed. On 3.11.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.