how get total of rows and columms?

Topics: Developer Forum
Dec 5, 2010 at 12:04 PM

hi,

i need import a xls file so far i have this:


$objReader = PHPExcel_IOFactory::createReader('Excel5');//use excel2007 for 2007 format
$objPHPExcel = $objReader->load("m.xls");
$val = ($objPHPExcel->getActiveSheet()->getCell('A1'));
$temp = $val->getvalue();//returns the value in the cell

 

with this i can open a file and load the cell a1 ok... but i need do something like this:

$cols = $objPHPExcel->total_colums

$rows = $objPHPExcel->total_rows

for ($j = 1;  $j<= $rows ; )     {

value = $objPHPExcel->getActiveSheet()->getCell(  row and colum  ));

}

how can i do that?

thanks for your help

:)

 

Coordinator
Dec 5, 2010 at 4:24 PM
$cols = $objPHPExcel->getActiveSheet()->getHighestColumn();
$rows = $objPHPExcel->getActiveSheet()->getHighestRow();
for ($i = 1;  $i<= $rows; $i++) {
   for ($j = 'A';  $j != $rcols; $j++) {
      $value = $objPHPExcel->getActiveSheet()->getCell($j.$i)->getValue();
      // do whatever you need with $value
   }
}

 

or look at the row and column iterators (see /Tests/28iterator.php for an example)