正在显示
1 个修改的文件
包含
6 行增加
和
3 行删除
| @@ -10,7 +10,7 @@ use App\Models\Aside\Domain\DomainInfo; | @@ -10,7 +10,7 @@ use App\Models\Aside\Domain\DomainInfo; | ||
| 10 | use Illuminate\Http\JsonResponse; | 10 | use Illuminate\Http\JsonResponse; |
| 11 | use PhpOffice\PhpSpreadsheet\Spreadsheet; | 11 | use PhpOffice\PhpSpreadsheet\Spreadsheet; |
| 12 | use PhpOffice\PhpSpreadsheet\Writer\Xlsx; | 12 | use PhpOffice\PhpSpreadsheet\Writer\Xlsx; |
| 13 | -use Illuminate\Support\Facades\Response; | 13 | + |
| 14 | 14 | ||
| 15 | /** | 15 | /** |
| 16 | * Class DomainInfoController | 16 | * Class DomainInfoController |
| @@ -170,9 +170,12 @@ class DomainInfoController extends BaseController | @@ -170,9 +170,12 @@ class DomainInfoController extends BaseController | ||
| 170 | $filePath = public_path('upload/excel/'.time().'.xlsx'); | 170 | $filePath = public_path('upload/excel/'.time().'.xlsx'); |
| 171 | // 导出 Excel 文件 | 171 | // 导出 Excel 文件 |
| 172 | $writer->save($filePath); | 172 | $writer->save($filePath); |
| 173 | + $header = [ | ||
| 174 | + 'Content-Description: File Transfer', | ||
| 175 | + 'Content-Type: application/octet-stream' | ||
| 176 | + ]; | ||
| 173 | // 返回导出文件的响应 | 177 | // 返回导出文件的响应 |
| 174 | - readfile($filePath); | ||
| 175 | - exit(); | 178 | + return response()->download($filePath,time().'.xlsx',$header)->deleteFileAfterSend(true); |
| 176 | } | 179 | } |
| 177 | 180 | ||
| 178 | } | 181 | } |
-
请 注册 或 登录 后发表评论