Search code examples
phpxlsx

PHP simplexlsx class error Call to a member function dimension() while parsing xlsx


During implementing class simplexlsx, while handling multiple sheets xlsx, I am getting an error:

Call to a member function dimension():

$xlsx = SimpleXLSX::parse('countries_and_population.xlsx')
list( $num_cols, $num_rows ) = $xlsx->dimension();

Any help?


Solution

  • Over searching solution, Found dimension wont work for all xlxs. I replace the code :-

    list( $cols, ) = $xlsx->dimension();

    to

     $sheet =$xlsx->sheetNames();
        foreach($sheet as $ky=>$rw) 
    

    This works without any issue for all xlsx