まずは、composer が必要らしい(php74 の部分は自分の環境にあわせる) php74 -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php74 composer-setup.php ./composer.phar -v mv composer.phar /usr/local/bin/composer.phar alias composer="php74 /usr/local/bin/composer.phar" composer -v zip が必要らしい yum install php74-php-pecl-zip cd /export/pc.yookies.jp composer init 殆ど、そのままでよい composer require phpoffice/phpspreadsheet ・使ってみる require_once('vendor/autoload.php'); use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Reader\Xls as XlsReader; use PhpOffice\PhpSpreadsheet\Reader\Xlsx as Reader; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; $SpreadSheet = new Spreadsheet(); $sheet = $SpreadSheet -> createSheet(0); $sheet -> setCellValue("A1", "a1"); $sheet -> setCellValue("B1", "b1"); $data_t = array('b2', 'b3', 'b4', ); $ct = 2; foreach ($data_t as $key => $val) { $sheet -> setCellValue("A" . $ct, $key); $sheet -> setCellValue("B" . $ct, $val); $ct++; } $xlsx = new Xlsx($SpreadSheet); $xlsx -> save("test.xlsx");
excel ファイルをつくってみる。