refactor: 修改各模块导出

This commit is contained in:
2025-04-02 16:23:29 +08:00
parent be737b3946
commit e750c8bbc7
11 changed files with 14 additions and 13 deletions

View File

@@ -115,13 +115,14 @@ if (!function_exists('xlsx_writer')) {
flush();
ob_flush();
if ($filename == '') $filename = date('YmdHis');
$filename = urlencode($filename);
// 文件写入缓冲区
\PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx')->save($output);
// 从缓冲区获取导出文件并通过Response返回解决thinkphp框架的Response无法获取设置的header问题
$file_data = ob_get_clean();
$response = \think\Response::create($file_data)->header([
'Access-Control-Expose-Headers' => 'Content-Disposition',
'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; Charset=UTF-8',
'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8',
'Content-Disposition' => 'attachment;filename=' . $filename . '.xlsx',
'Cache-Control' => 'max-age=0'
]);