0

我正在处理使用 maatwesite-excel(laravel excel)通过 phpexcel 加载的大型 excel 文件(~160k 行)。

虽然在使用“块”时我无法访问“noHeading()”。

Excel::filter('chunk')->load($pricefile->real_path)->chunk(250, function($reader)    {
    $reader = $reader->noHeading(); //Error: Method noHeading does not exist.
}

Excel::load($pricefile->real_path, function($reader){ 
    $reader = $reader->noHeading(); //array(0 => 'value', [...])
}

有任何想法吗?

4

2 回答 2

0

You're not getting a "reader" when using "chunk". In the case of chunk, you are getting the results directly, which you would otherwise get from the reader using

$reader->get();

So you got the results in your function, which do not have a method called "noHeading()".

I don't know if the headers are included there by default. You can get more details about chunks here:

http://www.maatwebsite.nl/laravel-excel/docs/import#chunk

于 2016-07-03T17:21:11.457 回答
0

这对我有用。

Excel::filter('chunk')->noHeading()->load($path)->chunk(250, function($results)
{
        foreach($results as $row)
        {
            // work in here               
        }
    });
于 2016-09-21T09:36:18.360 回答