title: PhpSpreadsheet how to export html with sub headers?
body: <p>ref: <a href="https://github.com/PHPOffice/PhpSpreadsheet/issues/1608" rel="nofollow noreferrer">https://github.com/PHPOffice/PhpSpreadsheet/issues/1608</a></p>
  <h3>What is the expected behavior?</h3>
  <p><img src="https://user-images.githubusercontent.com/7388088/89245092-5e654900-d608-11ea-9d9e-2445a4226c12.png" alt="html" /></p>
  <h3>Without Events</h3>
  <p><a href="https://i.stack.imgur.com/lwlHg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lwlHg.png" alt="enter image description here" /></a></p>
  <h3>What is the current behavior?</h3>
  <p><img src="https://user-images.githubusercontent.com/7388088/89245154-818ff880-d608-11ea-83d5-310f6733c822.png" alt="html" /></p>
  <h3>What are the steps to reproduce?</h3>
  <p>the issue is based on <code>Maatwebsite/Laravel-Excel</code> which internally use <code>PhpSpreadsheet</code> <a href="https://github.com/Maatwebsite/Laravel-Excel/issues/2784" rel="nofollow noreferrer">https://github.com/Maatwebsite/Laravel-Excel/issues/2784</a></p>
  <pre class="lang-html prettyprint-override"><code>&lt;table style=&quot;width:100%&quot; border=&quot;1&quot;&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              // ...
              &lt;th style=&quot;text-align: center;&quot; colspan=&quot;4&quot;&gt;{{ __('Items') }}&lt;/th&gt;
              // ...
          &lt;/tr&gt;
          &lt;tr&gt;
               // ...
          &lt;/tr&gt;
      &lt;/thead&gt;
  
      @foreach ($models-&gt;cursor() as $model)
          &lt;tbody&gt;
              &lt;tr&gt;
                  // ...
  
                  &lt;td colspan=&quot;4&quot;&gt;
                      &lt;table style=&quot;width:100%&quot;&gt;
                          @foreach ($model-&gt;relation as $item)
                              &lt;tr&gt;
                                  // ...
                              &lt;/tr&gt;
                          @endforeach
                      &lt;/table&gt;
                  &lt;/td&gt;
  
                  // ...
              &lt;/tr&gt;
          &lt;/tbody&gt;
      @endforeach
  &lt;/table&gt;
  </code></pre>
  <pre class="lang-php prettyprint-override"><code>// this works perfectly with single headers, but not with sub ones
  public function registerEvents(): array
      {
          return [
              AfterSheet::class =&gt; function (AfterSheet $event) {
                  $sheet = $event-&gt;sheet-&gt;getDelegate();
                  $sheet-&gt;getRowDimension(1)-&gt;setRowHeight(30);
  
                  $header = $sheet-&gt;getStyle('A1:' . $sheet-&gt;getHighestDataColumn() . '1');
                  $header-&gt;getAlignment()-&gt;setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
                  $header-&gt;getFont()-&gt;setBold(true);
                  $header-&gt;getFill()-&gt;setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)-&gt;getStartColor()-&gt;setARGB('00000000');
                  $header-&gt;getFont()-&gt;getColor()-&gt;setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_WHITE);
  
                  $other = $sheet-&gt;getStyle('A2:' . $sheet-&gt;getHighestDataColumn() . $sheet-&gt;getHighestRow());
                  $other-&gt;getAlignment()-&gt;setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_TOP);
  
                  foreach ([$header, $other] as $item) {
                      $item-&gt;getAlignment()-&gt;setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT);
                      $item-&gt;getAlignment()-&gt;setWrapText(true);
                  }
              },
          ];
      }
  </code></pre>
  <p>any help is appreciated &amp; if u need any more info plz ask.</p>