【发布时间】:2018-03-16 20:08:52
【问题描述】:
我正在使用 Laravel 中的 Maatwebsite/Laravel-Excel(2.1 版)库来下载 xls 文件。
class ControllerApi extends Controller {
private $excel;
public function __construct(Excel $excel) {
$this->excel = $excel;
}
public function getXlsFile(Request $request) {
$this->excel->create("Report2016", function($excel) {
// Set the title
$excel->setTitle('My awesome report 2016');
// Chain the setters
$excel->setCreator('Me')->setCompany('Our Code World');
$excel->setDescription('A demonstration to change the file properties');
$data = [12,"Hey",123,4234,5632435,"Nope",345,345,345,345];
$excel->sheet('Sheet 1', function ($sheet) use ($data) {
$sheet->setOrientation('landscape');
$sheet->fromArray($data, NULL, 'A3');
});
})->export("xlsx");
}
}
即使响应头看起来没问题,浏览器也不会下载文件。
谁知道我做错了什么?
提前致谢。
【问题讨论】:
标签: php http-headers laravel-5.1 xlsx