Vishal Desai
Vishal Desai

Reputation: 189

Reading csv with Laravel excel not working

I'm trying dd() output of a csv file, but I just get blank page.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Excel;

class TestController extends Controller
{

    public function test()
    {
        $file = Excel::load('public/hot.csv')->toArray();
        dd($file);
    }

}

I can see its loading the file because file is pretty big and I can see progress bar is taking while to load file when I visit the url that hits test() function.

Upvotes: 0

Views: 692

Answers (1)

Saad
Saad

Reputation: 1221

This is the proper way to use Excel::load.

Excel::load('public/hot.csv', function($reader) {
    $results = $reader->get();
    dd($results->toArray());
});

Upvotes: 1

Related Questions