I'm trying to set|persist some values in a Excel (.xlsx) file and I'm using phpoffice/phpexcel
library. This is how my code looks:
$objReader = \PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load($filename);
$objWorksheet = $objPHPExcel->getActiveSheet();
$objPHPExcel->getActiveSheet()->setCellValue('A'.$cRow, $hcpId); // set column A - HCP.ID - value
$objPHPExcel->getActiveSheet()->setCellValue('B'.$cRow, $terrID); // set column B - TERRITORY.ID - value
$objPHPExcel->getActiveSheet()->setCellValue('C'.$cRow, $isMatch); // set column C - isMatch TERR_HCP_XREF - value
echo "HCP.ID A{$cRow} => {$hcpId}, TERRITORY.ID B{$cRow} => {$terrID}, isMatch TERR_HCP_XREF {$isMatch} ", EOL;
And this is the result on the echo
sentence:
14:44:46 Load from Excel QXR_2015_Q3_PFE_V8_FINAL.xlsx file
HCP.ID A2 => 139810, TERRITORY.ID B2 => 453, isMatch TERR_HCP_XREF FALSE
HCP.ID A3 => 139810, TERRITORY.ID B3 => 560, isMatch TERR_HCP_XREF FALSE
HCP.ID A4 => 135453, TERRITORY.ID B4 => 442, isMatch TERR_HCP_XREF FALSE
HCP.ID A5 => 115075, TERRITORY.ID B5 => 445, isMatch TERR_HCP_XREF TRUE
Call time to read Workbook was 59.0086 seconds
14:45:45 Current memory usage: 409.5 MB
But is not working since columns hasn't values after run the script, why? What's wrong in my code? Did I miss something here?