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.
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"
You can rename your uploaded file as you want . you can use either move or storeAs method with appropiate param. Save this answer. Show activity on this post.
You have to create a collection and use it with a filter rather than an array. First trim the value as a space is not empty. Then make it a collection after that filter the empty row.
When dealing with big files, it's better to import the data in big chunks. You can enable this with filter('chunk') ; To import it into chunks you can use chunk($size, $callback) instead of the normal get() . The first parameter is the size of the chunk. The second parameter is a closure which will return the results.
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.
Probably something like:
Excel::load(public_path().'/bills/bill.template.xlsx', function($doc)
{...})
->setFilename('whatever')
->download('xlsx');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With