PHP Classes

large xlsx-files

Recommend this page to a friend!

      SimpleXLSX  >  All threads  >  large xlsx-files  >  (Un) Subscribe thread alerts  
Subject:large xlsx-files
Summary:missing fields in array
Messages:5
Author:Patrick
Date:2010-08-26 15:16:45
Update:2010-12-21 12:05:36
 

 


  1. large xlsx-files   Reply   Report abuse  
Picture of Patrick Patrick - 2010-08-26 15:16:45
Hi,
i use your class to handle some xlsx-files with a filesize round about 14MB.
Erverything works fine until i reached row 153 inside the file.
Till row 153 $xlsx_data=$xlsx->rows($sheet); returns the complete array with round about 70-80 elements. After row 153 the array contains only 25 elements.

The script runs on shell, so there is no memory error or something else.

Did you have any idea, or reason for this?

Regards Patrick

  2. Re: large xlsx-files   Reply   Report abuse  
Picture of Sergey Shuchkin Sergey Shuchkin - 2010-09-20 02:08:30 - In reply to message 1 from Patrick
patrick, plz give me your .xlst book to review, may be large file've other XML structure, I'll check it
sergey.shuchkin[ бульдог ]gmail.com

  3. Re: large xlsx-files   Reply   Report abuse  
Picture of Gonzo Gonzo - 2010-11-12 15:55:55 - In reply to message 2 from Sergey Shuchkin
Hi,
Empty field are not necessarily present in the XML structure of an XLSX file.

If my sheet is like this :
    |  A  |  B  |  C  |
  ---------------------
  1 |  v1 |  v2 |     |
  2 |      |  v3 |     |
  3 |      |       |  v4 |

The xml data of xlsx file is like this :
  <sheetData>
    <row r="1" spans="1:3">
      <c r="A1" t="s"><v>0</v></c>
      <c r="B1" t="s"><v>1</v></c>
    </row>
    <row r="2" spans="1:3">
      <c r="B2" t="s"><v>2</v></c>
    </row>
    <row r="3" spans="1:3">
      <c r="C3" t="s"><v>3</v></c>
    </row>
  </sheetData>

And the SimpleXLSX class return an array like this :
  Array (
    [0] => Array (
      [0] => v1
      [1] => v2
    )
    [1] => Array (
      [0] => v3
    )
    [2] => Array (
      [0] => v4
    )
  )

But is not correct.
The correct result is like this :
  Array (
    [0] => Array (
      [0] => v1
      [1] => v2
    )
    [1] => Array (
      [1] => v3
    )
    [2] => Array (
      [2] => v4
    )
  )

My patch :
In the function named "rows"
  - remove line 55 ($curC = 0;)
  - remove line 58 ($curC++;)
  - add after line 56 (foreach ($row->c as $c) {)
     |=> $curC = $this->_columnIndex((string) $c['r']);

Idem in the function "rowsEx"

Add the function "_columnIndex"
 |=>  function _columnIndex( $index = 'A1' ) {
        if (preg_match("/([$]?[A-Z]+)([$]?\d+)/", $index, $matches)) {
          $index = strtoupper($matches[1]);
          $strLen = strlen($index);
          $result = 0;
          for ($i=0; $i<$strLen; $i++) {
            $result += (ord($index{$strLen-$i-1}) - 64) * pow(26, $i);
          }
          return $result - 1;
        } else {
          throw new Exception("Invalid cell index.");
        }
      }

Thanks

  4. Re: large xlsx-files   Reply   Report abuse  
Picture of Tom Paul Grissom Tom Paul Grissom - 2010-12-03 20:54:19 - In reply to message 3 from Gonzo
Same issue, Patch resolved it.
thank you,

  5. Re: large xlsx-files   Reply   Report abuse  
Picture of Sergey Shuchkin Sergey Shuchkin - 2010-12-21 12:05:36 - In reply to message 1 from Patrick
fixed in repository

 
For more information send a message to info at phpclasses dot org.