Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading specific row or column - phpExcel

Using phpExcel, I have managed to read the whole worksheet. Is there a way I can read only certain values say from cell C15:C18, to insert them into the database?

like image 649
Alphy Avatar asked Jan 15 '23 05:01

Alphy


1 Answers

There are plenty of methods:

$cellValue = $objPHPExcel->getActiveSheet()->getCell('C15')->getValue();

will read the value of a specific cell (C15 in this case) into the variable $cellValue

or

$cellValues = $objPHPExcel->getActiveSheet()->rangeToArray('C15:C18');

will read a range of values to an array.

Once you've retrieved the contents of a cell to a normal PHP variable, it's easy enough to insert them into a database as you'd insert any data avalues into a database.

like image 182
Mark Baker Avatar answered Jan 21 '23 22:01

Mark Baker