「PHP開発」PHPExcelクラスでexcelデータを取得するコード

PHPコード:
require __DIR__ . './PHPExcel/IOFactory.php’;
$PHPReader = new \PHPExcel_Reader_Excel2007();

if (!$PHPReader->canRead($filePath)) {
$PHPReader = new \PHPExcel_Reader_Excel5();

if (!$PHPReader->canRead($filePath)) {
echo 'no Excel’;
return false;
}
}

$PHPExcel = $PHPReader->load($filePath);

$currentSheet = $PHPExcel->getSheet(0);
$allColumn = $currentSheet->getHighestColumn();

$allRow = $currentSheet->getHighestRow();

for ($currentRow = 1; $currentRow <= $allRow; $currentRow++) {

for ($currentColumn = 'A’; $currentColumn <= $allColumn; $currentColumn++) {
$val = $currentSheet->getCellByColumnAndRow(ord($currentColumn) – 65, $currentRow)->getValue();
$date[$currentRow – 1][] = $val;
}

}
return $date;

PHP

Posted by arkgame