导出优化

This commit is contained in:
2025-08-05 15:37:26 +08:00
parent c92e93968e
commit 0b4e3a3f31
2 changed files with 14 additions and 13 deletions
@@ -44,13 +44,14 @@ class CustomerController extends BaseController
*/
public function export(Request $request)
{
set_time_limit(120);
set_time_limit(300);
try {
$param = $request->all();
// $corp = Corp::where(['abbr' => $request->basic_data['corp_abbr']])->first();
// $param['corp_abbr'] = $corp->id;
$excelContent = (new CustomerService())->export($param);
$result = (new CustomerService())->export($param);
$excelContent = file_get_contents($result['filepath']);
// 生成文件名
$filename = '客户数据_' . date('Y-m-d_H-i-s') . '.xlsx';
return response()
+11 -11
View File
@@ -248,18 +248,18 @@ class CustomerService
// 创建Excel写入器
$writer = new Xlsx($spreadsheet);
// $writer->save($filepath);
$writer->save('php://output');
$excelContent = ob_get_clean();
return $excelContent;
$writer->save($filepath);
// $writer->save('php://output');
// $excelContent = ob_get_clean();
// return $excelContent;
// 返回文件信息
// return [
// 'filename' => $filename,
// 'filepath' => $filepath,
// 'size' => filesize($filepath),
// 'count' => count($customers)
// ];
// 返回文件信息
return [
'filename' => $filename,
'filepath' => $filepath,
'size' => filesize($filepath),
'count' => count($customers)
];
}
/**