php – 如何重命名文件 – >使用Laravel Excel下载()
发布时间:2020-12-14 19:44:28 所属栏目:大数据 来源:网络整理
导读:在Laravel Excel的文档中找不到如何在下载之前为加载的文件指定新名称.我试过了 – setTitle但它不起作用. Excel::load(public_path().'/bills/bill.template.xlsx',function($doc) { $doc-setTitle = 'test'; $sheet = $doc-setActiveSheetIndex(0); $sheet
在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'); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |