Row values in an array in phpexcel per line

Topics: Developer Forum
Oct 26, 2012 at 8:06 AM

Am trying to add values per line and the size of the array size should be the number of columns with values. Am new at using phpexcel.

 

$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(false);

$objPHPExcel = $objReader->load("test.xlsx");
$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);

$highestRow = $objWorksheet->getHighestRow(); // e.g. 10
$highestColumn = $objWorksheet->getHighestColumn(); // e.g 'F'

$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); // e.g. 5

$items[]=$values;

echo '<table>' . "\n";
for ($row = 1; $row <= $highestRow; ++$row) {
  echo '<tr>' . "\n";

  for ($col = 0; $col <= $highestColumnIndex; ++$col) {
  $values = '<td>' . $objWorksheet->getCellByColumnAndRow($col, $row)->getValue() . '</td>' . "\n";

 }

  echo '</tr>' . "\n";
}
echo '</table>' . "\n";

Coordinator
Oct 26, 2012 at 9:37 PM

So what's the actual problem?