Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

faizalanwar's avatar

Laravek Excel "Call to a member function setWorksheet() on array" when export multiple drawing laravel excel

I have export single image successfully. but I cant export multiple image. How to export multiple images in laravel excel ?

i get this error "Call to a member function setWorksheet() on array" using laravel excel maatwebsite-excel

public function drawings()
   {
       $Pengaduan = Pengaduan::select(
           'pengaduanTiket',
           'nama_lengkap',
           'no_hp',
           'no_kk',
           'no_ktp',
           'alamat_sesuai_ktp',
           'nama_pengaduan',
           'jenis_pengaduan',
           'isi_pengaduan',
           'status',
           'keterangan',
           'dokumen_pendukung',
           'dokumentasi',
           'lampiran',
       )->whereBetween('created_at', [$this->requestawal, $this->requestakhir])->get();


       $image1 = [];
       $image2 = [];
       $image3 = [];
       $rowNum = 2;
       foreach ($Pengaduan as $row) {

           $file1 = new Drawing();
           if ($row->dokumen_pendukung == null || $row->dokumen_pendukung == "") {
               $file1->setPath(public_path('/assets/images/default.jpg'));
           } else {
               $file1->setPath(public_path('/assets/uploads/images/pengaduan/') . $row->dokumen_pendukung);
           }
           $file1->setheight(20);
           $file1->setCoordinates('L' . $rowNum); 
           $image1[] = $file1;


           $file2 = new Drawing();
           if ($row->dokumentasi == null || $row->dokumentasi == "") {
               $file2->setPath(public_path('/assets/images/default.jpg'));
           } else {
               $file2->setPath(public_path('/assets/uploads/images/pengaduan/') . $row->dokumentasi);
           }
           $file2->setheight(20);
           $file2->setCoordinates('M' . $rowNum); 
           $image2[] = $file2;


           $file3 = new Drawing();
           if ($row->lampiran == null || $row->lampiran == "") {
               $file3->setPath(public_path('/assets/images/default.jpg'));
           } else {
               $file3->setPath(public_path('/assets/uploads/images/pengaduan/') . $row->lampiran);
           }
           $file3->setheight(20);
           $file3->setCoordinates('N' . $rowNum); 
           $image3[] = $file3;


           $rowNum++;
       }
       
       return [$image1, $image2, $image3];
   }

please help,

0 likes
1 reply
Snapey's avatar

share the error in full. You can get a share url from flare

Please or to participate in this conversation.