How to set bold rows while exporting to excel file.?

Viewed 495

I want to set bold rows(a1 to m1) while exporting excel file .. I have tried.

"$excel->getActiveSheet()->getStyle('A1:M1')->getFont()->setBold(true);"

but it gives error. This is my code.

Excel::create('Individual_data', function($excel) use($Indivudual_array) {
        $excel->setTitle('Individual_data');
        $excel->getActiveSheet()->getStyle('A1:M1')->getFont()->setBold(true);
        $excel->sheet('Individual_data', function($sheet)use($Indivudual_array) {
            $sheet->fromArray($Indivudual_array, null, 'A1', false, false);
        });
    })->download('xlsx');

While exporting excel file...this is error---

"Your requested sheet index: 0 is out of bounds. The actual number of sheets is 0" this error.

1 Answers

So I'm new to PhpSpreadsheet but I can share what I did and got the error away.

  1. Make sure the excel file is not locked or read only
  2. Ensure that the file is saved as the default excel(xlsx) not saved as Strict Open XML Spreadsheet(xlsx)
Related