I would like to update the cell value from excel file dynamically using phpofficespreadsheet library. The scenario is, get the mysql query as follow:
while($row = $query->fetch_assoc()) {
$datas = array(
'id' => $row['IdNumber']
'address' => $row['address']
);
And in my excel file at colum A contains idNumber, and at column B contains address.
What I tried so far is:
$inputFileName = 'datas.xlsx';
$inputFileType = ucfirst(substr($inputFileName, strrpos($inputFileName, '.') + 1));
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
$spreadsheet = $reader->load($inputFileName);
$sheet = $spreadsheet->getActiveSheet();
$last_row = (int) $sheet->getHighestRow();
//Update B column depends on A column as ID Number values
if($sheet->getCell('A')->getValue() == $datas['idNumber']){
$sheet->setCellValue('B', $datas['address']);
}
that's script return the wrong coordinates, Tried all the results i got from searchnig over the net, but not working. Anyone know how to achieved this?