|
|
@@ -5,7 +5,6 @@ namespace app\api\controller;
|
|
|
use app\common\controller\Api;
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
-use Symfony\Component\HttpFoundation\Response;
|
|
|
|
|
|
/**
|
|
|
* 包装计件单据维护接口
|
|
|
@@ -657,17 +656,18 @@ class PackagingCountDocument extends Api
|
|
|
}
|
|
|
}
|
|
|
$writer = new Xlsx($spreadsheet);
|
|
|
-// 创建响应对象并设置头信息
|
|
|
- $response = new Response(
|
|
|
- $writer->save('php://temp'),
|
|
|
- 200,
|
|
|
- [
|
|
|
- 'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
|
- 'Content-Disposition' => 'attachment;filename="' . $file_name . '.xlsx"'
|
|
|
- ]
|
|
|
- );
|
|
|
-
|
|
|
- return $response;
|
|
|
+ $save_path = 'uploads/' . $file_name . '.xlsx';
|
|
|
+
|
|
|
+ // 保存 Excel 文件到指定路径
|
|
|
+ $writer->save($save_path);
|
|
|
+
|
|
|
+ // 设置响应头信息
|
|
|
+ header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
|
+ header('Content-Disposition: attachment; filename="' . $file_name . '.xlsx"');
|
|
|
+ header('Content-Length: ' . filesize($save_path));
|
|
|
+
|
|
|
+ // 输出文件内容到客户端
|
|
|
+ readfile($save_path);
|
|
|
}
|
|
|
|
|
|
}
|