title: Adding Custom Footer and Header with Laravel Excel Package
body: <p>Am using Laravel Excel version 3.1 to generate CSV/XLS etc.
  I have to customized my csv or xls to have a custom footer and header spanned through the columns.</p>
  
  <p>Its should look like in the screenshot attached.</p>
  
  <p><a href="https://i.stack.imgur.com/cxc1w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cxc1w.png" alt="Expected output"></a></p>
  
  <p>Also, I want to store the exported file to storage location but cant make iy work.</p>
  
  <p>And the code I have done is: </p>
  
  <pre><code>class ReportExport implements FromArray, WithHeadings
  {
      protected $results;
  
      public function __construct(array $results, array $headings, array $fileAttributes)
      {
          $this-&gt;results = $results;
          $this-&gt;headings = $headings;
          $this-&gt;file_attributes = $fileAttributes;
      }
  
      /**
       * @return array
       */
      public function array(): array
      {
          return $this-&gt;results;
      }
  
      /**
       * @return array
       */
      public function headings(): array
      {
          return $this-&gt;headings;
      }
  
      public function registerEvents(): array
      {
          return [
              // Handle by a closure.
              BeforeExport::class =&gt; function(BeforeExport $event) {
                  $event-&gt;writer-&gt;getProperties()-&gt;setTitle('Patrick');
              },
          ];
      }
  
  }
  </code></pre>
  
  <p>Calling i as below:</p>
  
  <pre><code>Excel::store(["1","2"],"xyz.xlsx");
  </code></pre>
  
  <p>How can I add these extra lines to my exported results.</p>