title: While export to excel in laravel 4.2 from database
body: <p>Blade file:</p>
  
  <pre><code>&lt;div class="container"&gt;
     &lt;a href="{{ url::to('exportTo/xls') }}"&gt;&lt;button class="btn btn-primary"&gt;&lt;span class="glyphicon glyphicon-export"&gt;&lt;/span&gt; Export to xls&lt;/button&gt;&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public function exportTo($type)
  {
  
      $data = locations::get(['location_name','location_email'])-&gt;toArray();
             // dd($data);
  
      return Excel::create('export_to_excel_example', function($excel) use ($data) {
          $excel-&gt;sheet('mySheet', function($sheet) use ($data)
          {
              $sheet-&gt;fromArray($data);
          });
      })-&gt;download($type);
  }
  </code></pre>
  
  <p>Route file:</p>
  
  <pre><code>Route::get('exportTo/{type}', 'CustomerController@exportTo');
  </code></pre>
  
  <p>While exporting to excel in laravel 4.2 and it is redirected to index page, when i click on Export to xls link in blade file.</p>