title: export large data with chunk in Laravel-Excel
body: <p>With this code I can export to excel the data of MyModel, works ok:    </p>
  
  <pre><code>Excel::create('Filename', function ($excel) {
                  $excel-&gt;sheet('Contratos', function ($sheet) {
                      $datos = MyModel::select([
                          'id', 'data'])
                          -&gt;get();
                      $sheet-&gt;fromArray($datos, null, 'A1', false, false);
                  });
              })-&gt;export('xls');
  </code></pre>
  
  <p>But I need to chunk the data to generate the excel, because in another model I have too much data (like 9000 records). I was seein some examples like this one:</p>
  
  <p><a href="http://www.thecreativeroad.com/blog/export-large-dataset-using-laravel-excel-using-laravel-db-chunk" rel="nofollow noreferrer">http://www.thecreativeroad.com/blog/export-large-dataset-using-laravel-excel-using-laravel-db-chunk</a></p>
  
  <pre><code>$data = $user-&gt;query();
      try{
          return Excel::create('FileName', function($excel) use($data){
  
          $data-&gt;chunk(100, function ($users) use($excel) {
              $collection = $this-&gt;transformCollection($users);
  
              $excel-&gt;sheet('OrgSubUserList', function($sheet) use($collection){
                  $sheet-&gt;fromModel($collection, null, 'A1', true);
              });
          });
  
          })-&gt;export('xls');
      }
      catch(Exception $e)
      {
          return false;
      }
  </code></pre>
  
  <p>But I can't figure how to apply it to my code, I have a confusion between the order on the sheets and the file itself. Any hint?</p>