0、需要用到的 Library use \PhpOffice\PhpSpreadsheet\Spreadsheet; use \PhpOffice\PhpSpreadsheet\Writer\Xlsx; use \PhpOffice\PhpSpreadsheet\Reader\Xlsx; use \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; 參考資料: Welcome to PhpSpreadsheet's documentation - PhpSpreadsheet Documentation 1、上傳 excel 檔案並讀取內容 //處理上傳 try { $thefile = $this->request->getFile('theuploadfile'); } catch (\Exception $e) { echo $e; exit; } try { $path = $thefile->store(); } catch (\Exception $e) { echo $e; exit; } //確認檔案格式並讀取內容 $filename = WRITEPATH . 'uploads/' . $path; $fileext = ucfirst($thefile->getClientExtension()); if (in_array($fileext, array('Xls', 'Xlsx'))) { $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($fileext); $spreadsheet = $reader->load($filename); $sheet = $spreadsheet->getSheet(0); $data = $sheet->getCell('A1')->getValue(); } 2、產生 Excel 檔案 / /生成試算表並設定格式 $spreadsheet = new Spreadsheet(); $spreadsh...