hlyrain 2019-06-28
使用composer执行命令安装依赖:
composer require phpoffice/phpspreadsheet 版本号
代码示例:
<?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');