I have a file Excel contains 4 sheets. I imported just the first sheet but I want to import all the 4 sheets.
This is my code:
$objReader = PHPExcel_IOFactory::createReader(PHPExcel_IOFactory::identify($filePath));
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($filePath);
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
for ($row = 2; $row <= $highestRow; $row++){
/*echo $sheet->getCellByColumnAndRow(3, $row)->getCalculatedValue();
echo $sheet->getCellByColumnAndRow(4, $row)->getCalculatedValue();
echo $sheet->getCellByColumnAndRow(2,$row)->getCalculatedValue();*/
$listEquipement[] = new Article(
$sheet->getCellByColumnAndRow(2, $row)->getCalculatedValue(),
$sheet->getCellByColumnAndRow(3, $row)->getCalculatedValue(),
$sheet->getCellByColumnAndRow(5, $row)->getCalculatedValue()
);
}
return $listEquipement;
I found that I can use : getActiveSheet()
by adding replace this line:
$sheet = $objPHPExcel->getSheet(0);
By this:
$sheet = $objPHPExcel->getActiveSheet()->toArray(null, null, true, false);
Is this solution true ? Can someone help me.
Thank you in advance.