dimanche 6 octobre 2019

how to load images from an array in laravel-excel

I am using package Maatwebsite Laravel Excel version 3.1. I am constructing an Excel with some data including text and image. I would like to insert image file in excel while exporting the excel file. what should I do?

In Controller.php:

foreach ($persons as $slug => $person) {
       $row = array();
       foreach ($person as $key => $value) {
             if ($persons[$slug][$key]['type'] == 'image') {
                   array_push($row, public_path('/images/personal-image/' . $persons[$slug][$key]['answer']));
              } else {
                   array_push($row, $persons[$slug][$key]['answer']);
              }
       }

      array_push($rows, $row);

}

$coll = new participantExport([$rows]);

return Excel::download($coll, 'participant-information.xlsx');


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire