0

I am using Laravel Excel here is the version from composer

"maatwebsite/excel": "~2.1.0"

I am trying to pull data out of an excel document that only has cell A1 with data in it. When I try to var_dump the data coming from excel I get the title of the sheet an empty array. I would expect to see the value in A1.

Here is my code:

$data = Excel::load($path, function($reader) {})->get();
foreach ($data as $sheet) 
{
    var_dump($data);
    var_dump($sheet);
    foreach ($sheet as $row)
    {
        var_dump($row);
    }
}

Once again I only get the title of the sheet and an empty array with each var_dump. The value in cell A1 is "Test", so I shouldn't be receiving an empty array. A1 is the only cell with any value in it. When I upload other excel documents with more than just A1 filled out, I get an array full of all the rows in the document. How do I get the value of A1 in my excel document when it is the only value in the sheet?

user908759
  • 1,355
  • 8
  • 26
  • 48
  • http://www.maatwebsite.nl/laravel-excel/docs/import "By default the first row of the excel file will be used as attributes." – Mateusz Sip May 09 '17 at 00:26

1 Answers1

0

Am dealing with the same concept. My code is:

$leads  = Leads::select('company','firstname','lastname','title', 'email')->where('conferenceid', $id)->get()->toArray();
        if(empty($leads))
        {
            return Redirect::back()->with('danger','No data to download');
        }
        else
        {
        return Excel::create('Leads_List', function($excel) use ($leads) {
            $excel->sheet('Mysheet', function($sheet) use ($leads)
            {
                $sheet->fromArray($leads);
            });
        })->download();
        }
Kayal
  • 137
  • 3
  • 3
  • 11