|
|
@@ -5,6 +5,7 @@ namespace app\api\controller;
|
|
|
use app\common\controller\Api;
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
+use Symfony\Component\HttpFoundation\Response;
|
|
|
|
|
|
/**
|
|
|
* 包装计件单据维护接口
|
|
|
@@ -656,11 +657,17 @@ class PackagingCountDocument extends Api
|
|
|
}
|
|
|
}
|
|
|
$writer = new Xlsx($spreadsheet);
|
|
|
-
|
|
|
- header('Content-Disposition: attachment;filename="'.$file_name.'.xlsx"');
|
|
|
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
|
- return json($writer->save("php://output")); //表示在$path路径下面生成demo.xlsx文件
|
|
|
-
|
|
|
+// 创建响应对象并设置头信息
|
|
|
+ $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;
|
|
|
}
|
|
|
|
|
|
}
|