php - Cant read and manipulate excel data -
i'm trying read excel.xlsx
file. can't, i'm reading api called phpexcel
can't make work. tried:
<?php // access class require_once 'classes/phpexcel.php'; include 'classes/iofactory.php'; $inputfilename = 'teste.xlsx'; // read excel workbook try{ $inputfiletype = phpexcel_iofactory::identify($inputfilename); $objreader = phpexcel_iofactory::createreader($inputfiletype); $objphpexcel = $objreader->load($inputfilename); } catch(exception $e) { die('error loading file "'.pathinfo($inputfilename,pathinfo_basename).'": '.$e->getmessage()); } // worksheet dimensions $sheet = $objphpexcel->getsheet(0); $highestrow = $sheet->gethighestrow(); $highestcolumn = $sheet->gethighestcolumn(); // loop through each row of worksheet in turn ($row = 1; $row <= $highestrow; $row++){ // read row of data array $rowdata = $sheet->rangetoarray('a' . $row . ':' . $highestcolumn . $row,null, true, false); echo $rowdata[$row]; } ?>
at end of loop, tried read or echo
data, got errors like: undefined offset
.
Comments
Post a Comment