ob_end_clean(); ob_start(); Excel::create($filename, function($excel) use($records, $sheetname, $data) {}