I have written code for exporting the data(which is from Query builder) and downloading that sheet immediately to user's browser. I am using Laravel-Excel package for this, but the csv file is not getting downloaded.
I want the csv file to be 'Tab' delimited like below:
Supplier Campaign Disposition
sup-value1 cam-value1 dis-value1
sup-value2 cam-value2 dis-value2
sup-value3 cam-value3 dis-value3
My input as array is :
$results =
Array
(
[0] => Array
(
[Supplier] => Avikmithran
[Campaign] => krisha
[Disposition] => testing purpose
)
[1] => Array
(
[Supplier] => Avikmithran
[Campaign] => testscaseqwe
[Disposition] => this is the disposition
)
[2] => Array
(
[Supplier] => Avikmitra
[Campaign] => KrishnaL
[Disposition] => this is testing
)
[3] => Array
(
[Supplier] => Sonali
[Campaign] => starslab
[Disposition] => this is the disposiiton
)
)
CSV file download code is:
Excel::create('Statistics', function($excel) use($results) {
$excel->sheet('Statistics', function($sheet) use($results) {
$sheet->with($results);
});
})->export('csv');
It is driving the nuts, I have wasted 2 days on this already. Can anyone please tell me what is my mistake? Thanks.