title: PHPExcel: How to check whether a XLS file is valid or not?
body: <p>I'm using <code>PHPExcel 1.7.8</code> to read <code>.xls</code> files, uploaded by a radom user. All is working properly with a valid <code>.xls</code> file, but now I wanted to make some tests with invalid files to check if the program displays good error messages.</p>
  
  <p>So I took a <code>.csv</code> file, and renamed it with <code>.xls</code> (without converting anything, just changing the name) to the end, just to check...<br>
  Broken! :)</p>
  
  <pre><code>DOM ELEMENT: HTML
  DOM ELEMENT: BODY
  DOM ELEMENT: P
  START OF PARAGRAPH: 
  END OF PARAGRAPH:
  FLUSH CELL: A1 =&gt; block,date,hour...
  
  array
    1 =&gt;
      array
        'A' =&gt; string  'block,date,hour...' (length=2777)
  
  {"step":"error","errors":[],"warnings":[]}
  </code></pre>
  
  <p>Like you can see, there's an error message displaying, I didn't ask for that, and then the JSON that I usually write.</p>
  
  <p>It happens on this line :</p>
  
  <pre><code>&lt;?php
  echo "Loading file\n";
  try {
      if (!($objPHPExcel = PHPExcel_IOFactory::load('path'))) {
          echo "Failed\n";
          return;
          // ...
      }
  } catch(Exception $e) {
      echo 'Exception !';
  }
  echo "Done\n";
  </code></pre>
  
  <p>And this code displays:</p>
  
  <pre><code>Loading file
  /!\ ERROR MESSAGE ABOVE /!\
  Done
  </code></pre>
  
  <p>My question is, is there a way with PHPExcel or anything else to <strong>check whether a file is a valid XLS file</strong> before I try to parse it?</p>
  
  <p>Thank you.</p>