PHPExcel: won't read file, only when I first download it, put it in excel and put it back on the server -
so, our company have stock sync, every night our supplier put xlsx file on our server. worked great in beginning, discoverd sync broken.
the strange part here when download file computer , open excel en save file , upload on server, script read it...
so, when try read uploaded file won't work, when download file , open excel , save , upload on our server script read data fine.
anyone here has suggestion what's wrong ?
my code:
$lokaal_aanbodbestand="data/stocklistag_directly.xlsx"; //$lokaal_aanbodbestand="data/stocklistag_openedwithexcel.xlsx"; include("../../includes/phpexcel/iofactory.php"); $localsize = filesize ($lokaal_aanbodbestand); try { $inputfiletype = phpexcel_iofactory::identify($lokaal_aanbodbestand); print $inputfiletype."<br />"; $objreader = phpexcel_iofactory::createreader($inputfiletype); $objphpexcel = $objreader->load($lokaal_aanbodbestand); $sheet = $objphpexcel->getsheet(0); if(is_object($sheet)) { $highestrow = $sheet->gethighestrow(); $highestcolumn = $sheet->gethighestcolumn(); print "amout of row: ".$highestrow."<br />amout of columns".$highestcolumn."<br /><br />"; // 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); foreach($rowdata[0] $k=>$v) echo "row: ".$row."- col: ".($k+1)." = ".$v."<br />"; } } } catch (exception $e) { die('error loading file "' . pathinfo($inputfilename, pathinfo_basename) . '": ' . $e->getmessage()); } ?>
Comments
Post a Comment