toArray() issues

Topics: Developer Forum, User Forum
Mar 10, 2010 at 1:52 PM

Hi,

Two issues arise when using the function toArray() after having read an xls file.

Column letters like 'A', 'B', 'AX', etc are not being used as array keys, instead they are simply numbered. Is there a way to preserve column letters as array keys?

The seconds issue is the use of the function in combination with a read filter. At read excluded rows and columns are still being included in the generated array, though their values are 'null'. I'm only interested in the rows and columns which have actually been allowed by the read filter. With the issue mentioned above it is a bit understandable that this is the result. I do, however, find it unexpected behaviour since you specified what you actually want to use by the read filter. Is there a way to prevent this behaviour?

Developer
Mar 16, 2010 at 5:23 AM
Prodoc wrote:
Column letters like 'A', 'B', 'AX', etc are not being used as array keys, instead they are simply numbered. Is there a way to preserve column letters as array keys?

How about if we introduce a parameter $columnLetter = false|true in toArray() function ?

Prodoc wrote:
The seconds issue is the use of the function in combination with a read filter. At read excluded rows and columns are still being included in the generated array, though their values are 'null'. I'm only interested in the rows and columns which have actually been allowed by the read filter. With the issue mentioned above it is a bit understandable that this is the result. I do, however, find it unexpected behaviour since you specified what you actually want to use by the read filter. Is there a way to prevent this behaviour?

What you can do is to delete the columns after the read.

$worksheet->removeColumn('A', 1);