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

AbdulBazith's avatar

When the value 0 is exported, it is exported as an empty cell maatwebsite export in laravel

Guys iam working with project.

i used maatwebsite to export excel files.

my problem is when the value 0 is exported, it is exported as an empty cell

my code to export


 $ex = Personal_account::get();

 foreach($ex as $e)
       {

           $ex_array[]=array(

               ' Date'=>$e->date->format('d-m-Y'),
               ' Vendor Name'=>$e->vendor_name,
               'Vendor Location'=>$e->vendor_location,
               ' Vendor Booth'=>$e->vendor_booth,
               'Amount'=>$e->amount,
               'Note'=>$e->note,


           );
       }

       Excel::setValueBinder($valueBinder)->create('Personalaccounts', function($excel) use ($ex_array) {
                   $excel->sheet('mySheet', function($sheet) use ($ex_array)
                   {

                    $sheet->fromArray($ex_array);

                   });
              })->download('xlsx');


how to rectify this

Kindly help please

0 likes
1 reply
AbdulBazith's avatar
AbdulBazith
OP
Best Answer
Level 5

instead of doing

 $sheet->fromArray($ex_array);

do like this

$sheet->fromArray($ex_array, null, 'A1', true);

it works..!!

1 like

Please or to participate in this conversation.