When I download the csv:
54 is displayed instead of 00054. I'm using the next code:
$table = PldUsuario::all();
$output='';
foreach ($table as $row) {
$output.= implode(",",$row->toArray());
$output.= "
";
}
$headers = array(
'Content-Type' => 'text/csv',
'Content-Disposition' => 'attachment; filename="UsersPld.csv"',
);
return Response::make(rtrim($output, "
"), 200, $headers);
In my table in mysql displayed 00054.
To get excel to not remove the leading zeros, first make sure that they are a string in your initial array, then when setting them as the field in the CSV, it should read ,="00054"
. You'd probably need to go through your $row->toArray()
prior to imploding it to make those fields be "=\"00054\""
first.