「PHP開発」PHPExcel を使ってエクセルファイルを読み書き方法
phpコード
error_reporting(E_ALL);
date_default_timezone_set('Asia/Tokyo’);
include_once('Classes/PHPExcel/IOFactory.php’);
$filename = “employee.xls";
if (!file_exists($filename)) {
exit(“not found.\n");
}
$reader = PHPExcel_IOFactory::createReader('Excel5’);
$PHPExcel = $reader->load($filename);
$sheet = $PHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumm = $sheet->getHighestColumn();
$dataset=array();
for ($row = 1; $row <= $highestRow; $row++){
for ($column = 'A’; $column <= $highestColumm; $column++) {
$dataset[$row][] = $sheet->getCell($column.$row)->getValue();
echo $column.$row.":".$sheet->getCell($column.$row)->getValue()."<br />";
}
}