$file = 'upload/'.$filename;
//read file from path
$objPHPExcel = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel->setReadDataOnly(true);
$objPHPExcel = $objPHPExcel->load($file);
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
//$row = array();
for($row=1; $row <= $highestRow; ++$row){
for($col=0; $col <= $highestColumnIndex; ++$col){
$row[$col] = $objWorksheet->getCellByColumnAndRow($col,$row)->getValue();
}
}
echo "<pre>";print_r($row[$col]);echo "</pre>";
Here what is wrong with this $row
. it tells me that the value type of $row
is scalar. I am using array to put any cell from excel into my html.
I need to put this data into my mysql database. I'am using a Excel sheet, the sample sheet is :
(nama_lengkap, tempat_lahir, provinsi_lahir) ---> as header (Anak pertama, Jakarta, DKI) (Anak kedua, Bandung, Jawa Barat) (Anak ketiga, Semarang, Jawa Tengah)
Imagine table data:
| id | nama | tempat_lahir | provinsi_lahir |
|----|-------------|--------|-------|
| 1 | John | Semarang | Jawa tengah |
| 2 | Meresa | Bandung | Jawa Barat |
| 3 | Mike | Jakarta | Dki |