【发布时间】:2017-09-26 03:13:37
【问题描述】:
根据documentation,可以使用批处理加载文件。您还可以在大文件的情况下对数据进行分块。
分块:
Excel::filter('chunk')->load('file.csv')->chunk(250, function($results)
{
foreach($results as $row)
{
// do stuff
}
});
批量导入:
Excel::batch('app/storage/uploads', function($rows, $file) {
// Explain the reader how it should interpret each row,
// for every file inside the batch
$rows->each(function($row) {
// Example: dump the firstname
dd($row->firstname);
});
});
我有一系列大文件,我想知道是否可以将这两个函数链接在一起。问题是这两个函数都需要 2 个变量(第二个是 _callback),我不知道如何将它链接在一起。
现在看来唯一对我有用的是这样的东西,但我怀疑它实际上有什么作用:
Excel::filter('chunk')->batch('files', function($rows, $file){
【问题讨论】:
标签: php excel laravel csv maatwebsite-excel