没有通过maatwebsite / excel下载的csv文件没有内容

时间:2019-06-11 10:54:10

标签: laravel-5 export-to-csv maatwebsite-excel

在laravel 5.8中,我安装了maatwebsite / excel 在我的composer.json中:

.dropdown {
    ...
    padding: .5rem 1rem;
}

.navbar {
    padding: 0;
}

但是尝试将db中的数据上传到伪装成数组的数组:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "intervention/image": "^2.4",
        "laracasts/utilities": "^3.0",
        "laravel/framework": "5.8.*",
        "laravel/tinker": "^1.0",
        "maatwebsite/excel": "^3.1",
    },
...

我有file.csv uploade,但是它在syze和内容中有3个字节:

        $searchResultRows = SearchResult
            ::getByUserList($user_list_id)
            ->get()
            ->toArray();

//        echo '<pre>!!!count($searchResultRows))::'.print_r(count($searchResultRows),true).'</pre>';
//        echo '<pre>$searchResultRows)::'.print_r($searchResultRows,true).'</pre>';
        return \Excel::download( function ($excel) use ($searchResultRows) {
            $excel->sheet('mySheet', function ($sheet) use ($searchResultRows) {
                $sheet->fromArray($searchResultRows);
            });
        }, 'file.csv');

如果要取消对searchResultRows输出的2行的注释,我将按预期看到有效行。 怎么了?如何获取有效的csv文件?

谢谢!

0 个答案:

没有答案