1 year ago

Downloaded csv file with maatwebsite/excel has no content

Posted 1 year ago by mstdmstd

Hello, In laravel 5.8 I installed maatwebsite/excel and in my composer.json :

    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
    "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",

But trying to upload data from db convirted to array as :
        $searchResultRows = SearchResult

//        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) {
        }, 'file.csv');

I have file.csv uploade, but it has 3 bytes in syze and content :


If to uncomment 2 lines with searchResultRows output I see my valid rows as I expected. What is wrong and how to get valid csv file uploaded?


Please sign in or create an account to participate in this conversation.