protected function makeReport(Runner $runner) { $excel = new PHPExcel(); $sheet = $excel->setActiveSheetIndex(0)->setCellValue('A1', 'ID')->setCellValue('B1', 'Url地址')->setCellValue('C1', '请求方法')->setCellValue('E1', '测试结果')->setCellValue('F1', '备注'); foreach ($this->extractDataFromChain($runner->getExaminationChain()) as $key => $data) { $key += 2; $sheet->setCellValue("A{$key}", $data['name'])->setCellValue("B{$key}", $data['url'])->setCellValue("C{$key}", $data['method'])->setCellValue("E{$key}", $data['status'])->setCellValue("F{$key}", $data['remark']); } $writer = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007'); $filename = getcwd() . DIRECTORY_SEPARATOR . 'report.xlsx'; if (file_exists($filename)) { $filename = str_replace('.xlsx', time() . '.xlsx', $filename); } $writer->save($filename); }