Login   Register  
PHP Classes
elePHPant
Icontem

rows() returns rows without row indexes and skip empty rows

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Simple XLSX  >  All threads  >  rows() returns rows without row indexes and skip empty rows  >  (Un) Subscribe thread alerts  
Subject:rows() returns rows without row indexes and skip empty rows
Summary:...
Messages:1
Author:Dmitry Agutin
Date:2014-02-10 15:21:51
 

  1. rows() returns rows without row indexes and skip empty rows   Reply  
Picture of Dmitry Agutin
Dmitry Agutin
2014-02-10 15:21:52
Hello,

$xlsx->rows() skips empty rows and returns rows with no real index information.

Here is an example file:
http://www.sendspace.com/file/0fbh1i

It has data only on the 3rd row, in cella A3 and C3.

Let's consider the following code then:

$xlsx = new SimpleXLSX($fileName); // our test.xlsx
$dimensions = $xlsx->dimension();
$cells = $xlsx->rows();
$rowsEx = $xlsx->rowsEx();
print_r($dimensions);
print_r($cells);
print_r($rowsEx);

The following text is printed:

Array
(
[0] => 3
[1] => 3
)
Array
(
[0] => Array
(
[0] => test
[1] =>
[2] => testC
)

)
Array
(
[0] => Array
(
[0] => Array
(
[type] => s
[name] => A3
[value] => test
[href] =>
[f] =>
[format] =>
)

[1] => Array
(
[type] =>
[name] => B1
[value] =>
[href] =>
[f] =>
[format] =>
)

[2] => Array
(
[type] => s
[name] => C3
[value] => testC
[href] =>
[f] =>
[format] =>
)

)

)

I see the following problems here:

1) rows() skips empty rows that could lead to bugs if a client doesn't know about that. So I would at least write a PHPDoc comment that the function skips empty rows.
2) rows() returns an array in which there is no way to know real row indexes. As you can see in the printed array above (print_r($cells)), the single item in the array has an index of 0. I believe it would be much better if the key was 3, which would mean it's a 3rd row.
3) rowsEx() function returns information about cells, but you need to parse it to get row number and also it looks weird to me that the second cell in the row item has name B1 - shouldn't it be B3?

At the moment the most critical for me is to know real row index. For example, the old Spreadsheet_Excel_Reader returns an array of rows where keys are real row indexes (it's what I suggested above).