refactor: 修改各模块导出
This commit is contained in:
@@ -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'
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user