I am trying to export an excel with a stored procedure that I have created, for this I sent the parameters and everything is fine, it returns a complete array, but there are some null values.
Then I do the following (I 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 with use
in 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
Then I do not know if I get that error because I have null values or because it is done differently. The array has to be dynamic since I do all this with stored procedures and the columns can change.
I tried to do it in the following way but it does not 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);
}