SpartnerNL / Laravel-Excel

🚀 Supercharged Excel exports and imports in Laravel
https://laravel-excel.com
MIT License
12.12k stars 1.89k forks source link

How to use to a Newbie #199

Closed jpilldev closed 9 years ago

jpilldev commented 9 years ago

Hi.

I want to import the data from a csv file, i tried to read the docs but i am confuse on the use of this:

Excel::load('file.xls', function($reader) { })->get();

At first it seems to use in routes file but it doesn't work.

Thanks.

MaatwebsiteSupport commented 9 years ago

Hi,

I'm not the principal developer of this package but if I'm not mistaken you can get all rows from your CSV like so:

$sheet = Excel::load('file.csv')->get();

$sheet then contains a collection of all rows of your CSV file.

You can loop through them like:

// Loop through all rows
$sheet->each(function($row) {

});

You can always use Xdebug or dd($sheet); to inspect the contents.

jpilldev commented 9 years ago

Hi, it works, thanks for support.

weldan commented 9 years ago

Where should I put the excel file itself to be imported?

jpilldev commented 9 years ago

You can upload the file, look at this http://clivern.com/how-to-create-file-upload-with-laravel/

weldan commented 9 years ago

So I guess it would be in folder storage/ . thanks anyway