gpt4 book ai didi

php - 如何使用 Laravel Excel 在 ->download() 之前重命名文件

转载 作者:可可西里 更新时间:2023-11-01 13:49:42 26 4
gpt4 key购买 nike

在 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');

当我等待“test.xlsx”时,它给了我“bill.template.xlsx”

最佳答案

我以前没用过这个库,但是看代码好像可以set the filename attribute哪个will then get used in the headers to set the name of the file downloaded .

大概是这样的:

Excel::load(public_path().'/bills/bill.template.xlsx', function($doc) 
{...})
->setFilename('whatever')
->download('xlsx');

关于php - 如何使用 Laravel Excel 在 ->download() 之前重命名文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34183425/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com