I am trying to export an excel with a stored procedure that I have created, for this it sent the parameters and everything is fine, it returns a complete array, but there are some null values.
So I do the following (execute the query with static function)
$datos_mmu = S_Reporte_MMU_Cedente::get_reporte_mmu_cedente($id_cedente,$id_cartera,$tipo_mmu,$tipo_reporte);
Then I pass the data to use
Maatwebsite /excel (I have exported the excel facade), and I do it this way:
return Excel::create('Reporte Mmu', function($excel) use ($datos_mmu){
$excel->sheet('Excel sheet', function($sheet) use ($datos_mmu) {
$sheet->fromArray($datos_mmu);
});
})->export('xls');
But when I try to download it gives me the error
Object of class stdClass could not be converted to string
So I don't know if I get that error because I have null values or because it's done in another way. The array has to be dynamic since I do all this with stored procedures and the columns can change.
I have tried to do it in the following way but it doesn't work.
$array_data = [];
for ($c = 0;$c<sizeof($datos_mmu);$c++)
{
foreach ($datos_mmu[$c] as $i=>$cedente)
{
$array[$i] = (array)$cedente;
}
array_merge($array_data,$array);
}