导出优化
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user