title: Generate Word file in PHPWord in Laravel 5.8
body: <p>I am beginner in Laravel and I use Laravel 5.8 in my project.</p>
  
  <p>I have function to generate PDF file:</p>
  
  <pre><code>public function getCalendar(Request $request)
  {
          $month = $request-&gt;input('month');
  
          if ($month == null) {
              $now = Carbon::now();
              $month =  $now-&gt;month;
          }
  
          $events = $this-&gt;frontendGateway-&gt;getEventCalendarDownload($request, $month);
          $logo = public_path('assets/images/logo3.jpg');
  
          $pdf = \PDF::loadView('prints.events-view', ['events' =&gt; $events, 'logo' =&gt; $logo]);
          $pdf-&gt;setOptions(['isPhpEnabled' =&gt; true, 'dpi' =&gt; 150, 'setIsRemoteEnabled' =&gt; true]);
          $pdf-&gt;setPaper('A4', 'letter');
          return $pdf-&gt;download('Event Calendar' .  '-' . now()-&gt;toDateString() . '.pdf');
      }
  </code></pre>
  
  <p>My Blade:</p>
  
  <pre><code>&lt;div id="header" class="fontSize14"&gt;
      &lt;table width="100%"&gt;
          &lt;tr&gt;
              &lt;td align="left" style="width: 20%;"&gt;
                  &lt;img src="{{ $logo }}" class="logo" /&gt;
              &lt;/td&gt;
              &lt;td align="left" style="width: 80%;"&gt;
                  &lt;span class="fontSize19"&gt;&lt;b&gt;My name&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
                  street&lt;br /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  
  &lt;div id="content" class="fontSize11"&gt;
      &lt;b class="fontSize19"&gt;Calendar&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;
  
  
      &lt;table width="100%"&gt;
          &lt;thead style="background-color: lightgray;"&gt;
              &lt;tr&gt;
                  &lt;th&gt;#&lt;/th&gt;
                  &lt;th&gt;Data&lt;/th&gt;
                  &lt;th&gt;Godzina&lt;/th&gt;
                  &lt;th&gt;Nazwa imprezy&lt;/th&gt;
                  &lt;th&gt;Miejsce&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              @foreach($events as $event)
              @php
                  $hourFromX = explode(":", $event-&gt;hour_from);
                  $hourToX = explode(":", $event-&gt;hour_to);
                  $hourFrom = $hourFromX['0'].":".$hourFromX['1'];
                  $hourTo = $hourToX['0'].":".$hourToX['1'];
              @endphp
              &lt;tr&gt;
                  &lt;th scope="row"&gt;{{ $loop-&gt;iteration }}&lt;/th&gt;
              &lt;td&gt;{{ $event-&gt;date_from }}&lt;/td&gt;
              &lt;td align="left"&gt;{{ $hourFrom }}-{{ $hourTo }}&lt;/td&gt;
              &lt;td align="left"&gt;{{ $event-&gt;title }}&lt;/td&gt;
              &lt;td align="left"&gt;@if(isset($event-&gt;localization)) {{ $event-&gt;localization-&gt;name }},
                  {{ $event-&gt;localization-&gt;city }}
                  {{ $event-&gt;localization-&gt;street }} @endif&lt;/td&gt;
              &lt;/tr&gt;
              @endforeach
          &lt;/tbody&gt;
      &lt;/table&gt;
  
  
  &lt;/div&gt;&lt;div id="header" class="fontSize14"&gt;
      &lt;table width="100%"&gt;
          &lt;tr&gt;
              &lt;td align="left" style="width: 20%;"&gt;
                  &lt;img src="{{ $logo }}" class="logo" /&gt;
              &lt;/td&gt;
              &lt;td align="left" style="width: 80%;"&gt;
                  &lt;span class="fontSize19"&gt;&lt;b&gt;My name&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
                  street name
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  
  &lt;div id="content" class="fontSize11"&gt;
      &lt;b class="fontSize19"&gt;Kalendarz wydarzeń&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;
  
  
      &lt;table width="100%"&gt;
          &lt;thead style="background-color: lightgray;"&gt;
              &lt;tr&gt;
                  &lt;th&gt;#&lt;/th&gt;
                  &lt;th&gt;Data&lt;/th&gt;
                  &lt;th&gt;Godzina&lt;/th&gt;
                  &lt;th&gt;Nazwa imprezy&lt;/th&gt;
                  &lt;th&gt;Miejsce&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              @foreach($events as $event)
              @php
                  $hourFromX = explode(":", $event-&gt;hour_from);
                  $hourToX = explode(":", $event-&gt;hour_to);
                  $hourFrom = $hourFromX['0'].":".$hourFromX['1'];
                  $hourTo = $hourToX['0'].":".$hourToX['1'];
              @endphp
              &lt;tr&gt;
                  &lt;th scope="row"&gt;{{ $loop-&gt;iteration }}&lt;/th&gt;
              &lt;td&gt;{{ $event-&gt;date_from }}&lt;/td&gt;
              &lt;td align="left"&gt;{{ $hourFrom }}-{{ $hourTo }}&lt;/td&gt;
              &lt;td align="left"&gt;{{ $event-&gt;title }}&lt;/td&gt;
              &lt;td align="left"&gt;@if(isset($event-&gt;localization)) {{ $event-&gt;localization-&gt;name }},
                  {{ $event-&gt;localization-&gt;city }}
                  {{ $event-&gt;localization-&gt;street }} @endif&lt;/td&gt;
              &lt;/tr&gt;
              @endforeach
          &lt;/tbody&gt;
      &lt;/table&gt;
  
  
  &lt;/div&gt;
  </code></pre>
  
  <p>It's work fine.</p>
  
  <p>Now I want make generate Word file.
  I found this lib: <a href="https://github.com/PHPOffice/PHPWord" rel="nofollow noreferrer">https://github.com/PHPOffice/PHPWord</a></p>
  
  <p>I try change my function to this lib (export to Word file):</p>
  
  <p>use PhpOffice\PhpWord\PhpWord;
  ....</p>
  
  <pre><code>public function getCalendar(Request $request)
      {
          $month = $request-&gt;input('month');
          if ($month == null) {
              $now = Carbon::now();
              $month =  $now-&gt;month;
          }
          $events = $this-&gt;frontendGateway-&gt;getEventCalendarDownload($request, $month);
          $logo = public_path('assets/images/logo3.jpg');
  ...
      }
  </code></pre>
  
  <p>How can I add my data and view to Word?</p>