There are four rows in set while I simply print all rows shown but exporting data could not work in the following code. Could anybody identify where I am doing wrong?
$reportdata=DB::select($query);
$filename = "beema_report_" . date('Ymd') . ".xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
header("Pragma: no-cache");
header("Expires: 0");
print('Sn'."\tBijak Numbber\t Issued Date \t Bill No \t Insured Name \t Policy Number \t General Premium \t Terrorism Premium \t Stamp Duty \t Vat \t Total Premium \t Motor General\t Motor TPL \t Motor Workers\t Motor Risk
");
$sn=1;
foreach($reportdata as $report)
{
$totalgeneral+=$report->general_premium;
$totalrisk+=$report->risk;
$totalstamp+=$report->stamp;
$totalvat+=$report->vat;
$totalsumtotal+=$report->sum_total;
$totalgen+=$report->gen;
$totaltpl+=$report->tpl;
$totalworkers+=$report->workers;
echo $sn."\t";
echo $report->bijak_no."\t";
echo $report->issued_date."\t".$report->bill_no." \t".$report->ins_name." \t".$report->policy_no." \t".$report->general_premium." \t". $report->risk." \t". $report->stamp." \t".$report->vat."\t". $report->sum_total." \t". $report->gen. "\t".$report->tpl." \t".$report->workers."\t". $report->risk."
";
$sn++;
}
In the above code, only three rows are exported to the excel. It seems fine but last row could not exported, What's the problem there?