title: PhpOffice\PhpSpreadsheet\Reader\Exception Failed to load .... as a DOM document
body: <p>When I try to export datas as excel file on the specific request I got below error</p>
  <blockquote>
  <p>PhpOffice\PhpSpreadsheet\Reader\Exception
  Failed to load path_to_project\storage\framework\laravel-excel\laravel-excel-pz23rYwVENIOZUw7vnvhKaNjUkkNLNT8.html as a DOM Document</p>
  </blockquote>
  <p>I search alot but couldnot find any answer, the problem comes only when <code>semester = First Sem</code> but when semester is second, third etc this error doesn't come and I can download excel.</p>
  <p>Below are my code</p>
  <pre><code>Route::get('/export', function () {
    return Excel::download(new ReportExport(request()-&gt;exams, request()-&gt;course, request()-&gt;semesterName), ''.request()-&gt;course.' '.request()-&gt;semesterName.'('.request()-&gt;exams.').xlsx');
  })
  
  // ReportExcel.php
  $data = Fee::with(['backpapers' =&gt; function($bp) use ($myCourse, $semName) {
              $bp-&gt;where('course_name', $myCourse)-&gt;where('semester', $semName);
          }])-&gt;get();
  
   $table = '&lt;table class=&quot;table table-border table-hover&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;#&lt;/th&gt;&lt;th&gt;Roll No&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Reg_No&lt;/th&gt;&lt;th&gt;Father\'s Name&lt;/th&gt;&lt;th&gt;Gender&lt;/th&gt;&lt;th&gt;Aadhaar No&lt;/th&gt;&lt;th&gt;Mobile&lt;/th&gt;&lt;th&gt;Email&lt;/th&gt;&lt;th&gt;Paper 1&lt;/th&gt;&lt;th&gt;Paper 2&lt;/th&gt;&lt;th&gt;Paper 3&lt;/th&gt;&lt;th&gt;Paper 4&lt;/th&gt;&lt;th&gt;Exam Fee&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;';
  
   $count = 1;
   foreach ($data as $key =&gt; $bp) {
    if (count($bp-&gt;backpapers) &gt; 0) {
      $table .= '&lt;tr&gt;&lt;td&gt;'.$count.'&lt;/td&gt;&lt;td&gt;'.$bp-&gt;roll_number.'&lt;/td&gt;&lt;td&gt;'.$bp-&gt;name.'&lt;/td&gt;&lt;td&gt;'.($bp-&gt;registration_number != null ? $bp-&gt;registration_number : '-').'&lt;/td&gt;&lt;td&gt;'.$bp-&gt;father_name.'&lt;/td&gt;&lt;td&gt;'.($bp-&gt;gender == 1 ? 'Male' : 'Female').'&lt;/td&gt;&lt;td&gt;'.($bp-&gt;aadhaar_number != null ? $bp-&gt;aadhaar_number : '-').'&lt;/td&gt;&lt;td&gt;'.$bp-&gt;mobile_number.'&lt;/td&gt;&lt;td&gt;'.($bp-&gt;email != null ? $bp-&gt;email : '-').'&lt;/td&gt;';
      
      $paperFee = BackpaperFee::where('number_of_paper', count($bp-&gt;backpapers))-&gt;pluck('fee_amount')-&gt;first();
      if (count($bp-&gt;backpapers) == 4) {
          foreach ($bp-&gt;backpapers as $bpp) {
              $table .= '&lt;td&gt;'.$bpp-&gt;paper_name.'&lt;/td&gt;';
          }
      } elseif (count($bp-&gt;backpapers) == 3) {
          foreach ($bp-&gt;backpapers as $bpp) {
              $table .= '&lt;td&gt;'.$bpp-&gt;paper_name.'&lt;/td&gt;';
          }
          $table .= '&lt;td&gt;-&lt;/td&gt;';
      } elseif (count($bp-&gt;backpapers) == 2) {
          foreach ($bp-&gt;backpapers as $bpp) {
              $table .= '&lt;td&gt;'.$bpp-&gt;paper_name.'&lt;/td&gt;';
          }
          $table .= '&lt;td&gt;-&lt;/td&gt;&lt;td&gt;-&lt;/td&gt;';
      } elseif (count($bp-&gt;backpapers) == 1) {
          foreach ($bp-&gt;backpapers as $bpp) {
              $table .= '&lt;td&gt;'.$bpp-&gt;paper_name.'&lt;/td&gt;';
          }
          $table .= '&lt;td&gt;-&lt;/td&gt;&lt;td&gt;-&lt;/td&gt;&lt;td&gt;-&lt;/td&gt;';
      }
  
      $table .= '&lt;td&gt;'.$paperFee.'&lt;/td&gt;&lt;/tr&gt;';
      $count++;
    }
   }
   $table .= '&lt;/tbody&gt;&lt;/table&gt;';
   
   return view('excel', compact('table'));
  </code></pre>
  <p>Like I said earlier, the error occurs when <code>semester=First Sem</code> only.</p>
  <p>I tried:</p>
  <ol>
  <li><code>php artisan cache:clear</code></li>
  <li><code>php artisan route:clear</code></li>
  <li><code>php artisan view:clear</code></li>
  <li><code>php artisan config:clear</code></li>
  </ol>
  <p>But nothing works.. Thanks in advance</p>