title: Reading data from an excel file using PhpOffice\PhpSpreadsheet in symfony 4
body: <p>I develop an application with symfony 4 and I need to read data from an excel file. I integrate PhpOffice \ PhpSpreadsheet in my project but I can not find documentation to use it for now. I find this site to start but it does not do everything I want. <a href="https://phpspreadsheet.readthedocs.io/en/latest/topics/reading-and-writing-to-file/" rel="nofollow noreferrer">https://phpspreadsheet.readthedocs.io/en/latest/topics/reading-and-writing-to-file/</a></p>
  
  <p>If someone would have another track or know how to read data from an excel file using PhpSpreadsheet.</p>
  
  <pre><code>public function excelReader(){
  
      $reader = new Xlsx();
      $reader-&gt;setReadDataOnly(TRUE);
      $spreadsheet = $reader-&gt;load("test.xlsx");
      $worksheet = $spreadsheet-&gt;getActiveSheet();
  
      $highestRow = $worksheet-&gt;getHighestRow(); 
      $highestColumn = $worksheet-&gt;getHighestColumn(); 
      $highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($highestColumn);
  $res = array();
      for($row=1; $row &lt; $highestRow ; $row++){
          for($col = 1; $col &lt;= $highestColumnIndex; $col++){
              $value = $worksheet-&gt;getCellByColumnAndRow($col,$row)-&gt;getValue();
              array_push($res,$value);
          }
      }
  
  
      return $this-&gt;render('table/excel.html.twig', [
          'list' =&gt; $res,
      ]);
  
   }
  </code></pre>
  
  <p>in this code I try to load and then read the test.xlsx file that I put in the controller folder. I get the following error: File "test.xlsx" does not exist.</p>