使用composer執行命令安裝依賴:php
composer require phpoffice/phpspreadsheet 版本號
代碼示例:composer
<?php date_default_timezone_set("PRC");//時區設置 require 'vendor/autoload.php'; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->setCellValue('A1', 'Hello World !'); $writer = new Xlsx($spreadsheet); $writer->save('hello world.xlsx');