Can't find in docs of Laravel Excel how to give a new name for loaded file before give it for download. I've tried ->setTitle but it doesn't work.
在Laravel Excel的文档中找不到如何在下载之前为加载的文件指定新名称。我试过 - > setTitle但它不起作用。
Excel::load(public_path().'/bills/bill.template.xlsx', function($doc) {
$doc->setTitle = 'test';
$sheet = $doc->setActiveSheetIndex(0);
$sheet->setCellValue('G21', '{buyer}');
$sheet->setCellValue('AB24', '{sum}');
$sheet->setCellValue('B30', '{sum_propis}');
})->download('xlsx');
It gives me "bill.template.xlsx" when I'm waiting for "test.xlsx"
当我在等待“test.xlsx”时,它给了我“bill.template.xlsx”
1 个解决方案
#1
6
I haven't used this library before, but looking at the code it looks like you can set the filename attribute which will then get used in the headers to set the name of the file downloaded.
我以前没有使用过这个库,但看看代码看起来你可以设置filename属性,然后在头文件中使用它来设置下载文件的名称。
Probably something like:
可能类似于:
Excel::load(public_path().'/bills/bill.template.xlsx', function($doc)
{...})
->setFilename('whatever')
->download('xlsx');
#1
6
I haven't used this library before, but looking at the code it looks like you can set the filename attribute which will then get used in the headers to set the name of the file downloaded.
我以前没有使用过这个库,但看看代码看起来你可以设置filename属性,然后在头文件中使用它来设置下载文件的名称。
Probably something like:
可能类似于:
Excel::load(public_path().'/bills/bill.template.xlsx', function($doc)
{...})
->setFilename('whatever')
->download('xlsx');