title: Reading File With PhpSpreadsheet Sheet Out of Bounds Error
body: <p>Trying to read from a <strong>XLSX</strong> file with <strong>PhpSpreadsheet</strong> however  getting below error:</p>
  <pre><code>PHP Fatal error:  Uncaught PhpOffice\PhpSpreadsheet\Exception: Your requested sheet index: -1 is out of bounds. The actual number of sheets is 0. in C:\php\projects\stock\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Spreadsheet.php:678
  </code></pre>
  <p>There is definitely a worksheet and my code below to pull a single cell works fine when I remove the table and just have unformatted data.</p>
  <pre><code>$spreadsheet = new PhpOffice\PhpSpreadsheet\Spreadsheet();
  
  $inputFileName = &quot;path/to/temp_file_download.xlsx&quot;;
  $inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($inputFileName);
  $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
  $spreadsheet = $reader-&gt;load($inputFileName);
  echo $cellValue = $spreadsheet-&gt;getActiveSheet()-&gt;getCellByColumnAndRow(2, 2)-&gt;getValue();
  </code></pre>
  <p>It seems that saving the file with Excel allows it to work just fine however excel does not complain that it is corrupt etc. I have no control over the actual spreadsheet as generated from an external source.</p>
  <p>Just wondering if anyone has had similar issues and have any ideas for working around or what I may be doing wrong?</p>
  <p>Tried to use the older PhpExcel also to get this to work however similar issues occur until I save the file again.</p>
  <p>Have also tried XLSXReader with similar issues:</p>
  <pre><code>PHP Fatal error:  Uncaught Exception: File /xl/workbook.xml does not exist in the Excel file in C:\php\projects\stock\vendor\XLSXReader\XLSXReader.php:57
  Stack trace:
  #0 C:\php\projects\stock\vendor\XLSXReader\XLSXReader.php(70): XLSXReader-&gt;getEntryData()
  #1 C:\php\projects\stock\vendor\XLSXReader\XLSXReader.php(47): XLSXReader-&gt;parse()
  #2 C:\php\projects\stock\stock.php(17): XLSXReader-&gt;__construct()
  #3 {main}
    thrown in C:\php\projects\stock\vendor\XLSXReader\XLSXReader.php on line 57
  </code></pre>
  <p>And have seen many issues on web for people having issues reading these files that area created like so however still not sure of a simple workaround.</p>