Search code examples
phpexcellaravelmaatwebsite-excel

how to add custom data in excel file laravel


I am using Maatwebsite to export data from Laravel to Excel, but it only throws a junk of data in it, I want to custom design how I want to insert the data in.

for example I want to add tittle at lane C 4 I want to do something like

$column->atAtSpecificRow('C', '4', $title);

I don't know if that works or how it can work, so any suggestion?

UPDATE: I use this to export an array of data

$sheet->fromArray($data);
$sheet->setCellValue('D5', 'Test');

I want to add data from cell D5 and lower, how can I do that?


Solution

  • What you mean from the cell D5 and lower? You could use a loop to go from D5 and below...

    for($x=6; $x<30; $x++)
    {
       $sheet->setCellValue('D'.$x, 'Row '. $x);
    }