Something like you have should be fine. I would recommend you to build the data array first and then append everything at one. This was you can debug the data output without generating a new excel sheet every time ;)
Jul 12, 2016
5
Level 5
Maatwebsite Excel export data from database
Hey !
I had a issue with passing data to column depend on other value im passing data like this
$sum = Tour::where('receipt_amount','>=',25000)->count();
$data = array('DATE','RECEIPT NO','AMOUNT','STAMP DUTY');
$sheet->fromArray(array($data),null,'A5',false,false);
$i =0;
foreach($jobs as $index => $row){
$data=array($row->receipt_date,$row->receipt_no,$row->receipt_amount);
$sheet->fromArray(array($data),null,'A5',false,false);
$i++;
$sheet->appendRow($i+7, array(
'', '','Total',$sum*25
));
}
How to put the value in a fourth column if $row->receipt_amount is > 25000 then fourth column shoud be show 25.00 Rs. How can do this ?
Level 5
@bobbybouwmann bad coding i know but i did
foreach($jobs as $index => $row){
$data=array($row->receipt_date,$row->receipt_no,$row->receipt_amount,"=IF($row->receipt_amount>25000,25,0)");
$sheet->fromArray(array($data),null,'A5',false,false);
}
Please or to participate in this conversation.