phpspreadsheet

简介

Excel导入导出都需要它不多说

环境要求

  1. InitAdmin >= 201903
  2. PHP >= 5.6
  3. PHP extension php_zip enabled
  4. PHP extension php_xml enabled
  5. PHP extension php_gd2 enabled

安装扩展

  1. cd actionphp/vendor
  2. composer require phpoffice/phpspreadsheet

基本用法

  1. $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
  2. $sheet = $spreadsheet->getActiveSheet();
  3. $sheet->setCellValue('A1', 'Hello World !');
  4. $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
  5. $writer->save('hello world.xlsx');

英文文档地址

https://phpspreadsheet.readthedocs.io/en/latest/