composer require phpoffice/phpspreadsheet
現在メンテナンスされていません
composer require phpoffice/phpexcel
require_once __DIR__ . '/vendor/autoload.php';
$excel_file = 'myfile.xlsx';
// ファイルの読み込み
$objPHPExcel = PHPExcel_IOFactory::load( './' . $excel_file );
$objPHPExcel->setActiveSheetIndex(0); // 先頭のシートを選択
$sheet = $objPHPExcel->getActiveSheet();
foreach ($sheet->getRowIterator() as $row) {
$tmp = array();
foreach ($row->getCellIterator() as $cell) {
$tmp[] = $cell->getValue();
}
print_r( $tmp );
}
$objPHPExcel = new PHPExcel();
$sheet = $objPHPExcel->getActiveSheet();
for ($i=0; $i <= 10 ; $i++) {
$sheet->setCellValueByColumnAndRow($i, 3, "テスト{$i}");
}
$writer = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$writer->save('___test.xlsx');