PHP Classes

SimpleXLSX dimension returns 0 cols and 0 rows

Recommend this page to a friend!

      SimpleXLSX  >  All threads  >  SimpleXLSX dimension returns 0 cols...  >  (Un) Subscribe thread alerts  
Subject:SimpleXLSX dimension returns 0 cols...
Summary:dimension
Messages:3
Author:André Boni
Date:2018-06-16 17:34:32
 

  1. SimpleXLSX dimension returns 0 cols...   Reply   Report abuse  
Picture of André Boni André Boni - 2018-06-16 17:34:32
hi,

I have an Excel file with 5 lines and 40 columns. I want to my user insert column name and lines values in a database table.

In my code I did this :

if ( $xlsx = SimpleXLSX::parse( $_FILES['file']['tmp_name'] ) )
{
list( $num_cols, $num_rows) = $xlsx->dimension();
foreach ( $xlsx->rows() as $k => $r ) {
for ( $i = 0; $i < $num_cols; $i ++ ) {
echo $r[$i];
}
}
}

Never give the echo command because not passed into for loop

Can you help me, please ?

Thks

  2. Re: SimpleXLSX dimension returns 0 cols...   Reply   Report abuse  
Picture of Sergey Shuchkin Sergey Shuchkin - 2018-06-16 18:19:46 - In reply to message 1 from André Boni
don't trust ->dimension

extract your cells

foreach( $xlsx->rows as $r ) {
foreach( $r as $cell ) ...

  3. Re: SimpleXLSX dimension returns 0 cols...   Reply   Report abuse  
Picture of André Boni André Boni - 2018-06-16 21:39:51 - In reply to message 2 from Sergey Shuchkin
Hi, Sergey

Thks for your help. If I need to read rowsEx to get cell format, I do the same way ?

Regards,

André