jeudi 24 novembre 2016

laravel excel get headers and maatwebsite

I want to get only my excel first column that will be column name.

I am using this code

Excel::load($request->file, function ($reader) use($request) {

$torarray=$reader->toArray();
            $line0 = $torarray[0];
            $headers = array_keys($line0);
            $excel_header=$headers;
        });

Sometimes it works but some times not work. when not work with some files the i write below that and works

$torarray=$reader->toArray();
            $line0 = $torarray[0][0];
            $headers = array_keys($line0);
            $excel_header=$headers;
        });

I cant understand whats the correct solution.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire