Tuesday, March 13, 2018

Loading a view with laravel Excel - development

Loading a view with laravel Excel

I’m trying to export a view in laravel, using

https://github.com/Maatwebsite/Laravel-Excel

The problems is that I’m getting this error with my css file "file_get_contents(/css/all.css): failed to open stream: No such file or directory" It could not find my file when I press the button to export, but if I don’t my page loads normally, once i had this same problem and i just had to go one folder back to access to my files, but it didnt work this time

this is my code in my controller

    public function exportar($empresa_id, $id)
    {
        $empresa = Empresa::where('id', $empresa_id)->first();
        $transferencia = $empresa->transferencias()->where('transferencia_id', $id)->first();
        $destino = Empresa::where('nombre', $transferencia->destino)->first();
        Excel::create('New file', function ($excel) use ($empresa, $transferencia, $destino) {

            $excel->sheet('New sheet', function ($sheet) use ($empresa, $transferencia, $destino) {

                $sheet->loadView('acciones/imprimirTransferencia', array('empresa' => $empresa, 'transferencia' => $transferencia, 'destino' => $destino));

            });

        })->export('xls');

    }

My css link

  <link href="" rel="stylesheet" type="text/css"/>

My button

  <a href="" id="exportar_excel" class="btn btn-success pull-right"> Generar PDF                
 </a>



from Laravel Questions and Answers https://laravelquestions.com/php/loading-a-view-with-laravel-excel/
via Lzo Media

No comments:

Post a Comment