title: Reading spreadsheet using PHPExcel
body: <p>I'm trying to upload a spreadsheet and read it into a MySQL database using PHPExcel.</p>
  
  <p>For .xlsx files it works fine but whenever I try to upload a .ods file it throws the error: PHP Fatal error: Call to a member function getNamespaces() on a non-object in PHPExcel_1.7.9/Classes/PHPExcel/Reader/OOCalc.php on line 341</p>
  
  <p>What's going wrong?</p>
  
  <p>HTML Form:
  </p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form method="post" enctype="multipart/form-data"&gt;
  Upload File: &lt;input type="file" name="spreadsheet"/&gt;
  &lt;input type="submit" name="submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>PHP (In same file):
  
      
  
  <pre class="lang-php prettyprint-override"><code>//Check valid spreadsheet has been uploaded
  if(isset($_FILES['spreadsheet'])){
  if($_FILES['spreadsheet']['name']){
      if(!$_FILES['spreadsheet']['error'])
      {
  
          $inputFile = $_FILES['spreadsheet']['name'];
          $extension = strtoupper(pathinfo($inputFile, PATHINFO_EXTENSION));
          if($extension == 'XLSX' || $extension == 'ODS'){
  
              //Read spreadsheeet workbook
              try {
                   $inputFile = $_FILES['spreadsheet']['tmp_name'];
                   $inputFileType = PHPExcel_IOFactory::identify($inputFile);
                   $objReader = PHPExcel_IOFactory::createReader($inputFileType);
                   $objPHPExcel = $objReader-&gt;load($inputFile);
              } catch(Exception $e) {
                      die($e-&gt;getMessage());
              }
  
              //Get worksheet dimensions
              $sheet = $objPHPExcel-&gt;getSheet(0); 
              $highestRow = $sheet-&gt;getHighestRow(); 
              $highestColumn = $sheet-&gt;getHighestColumn();
  
              //Loop through each row of the worksheet in turn
              for ($row = 1; $row &lt;= $highestRow; $row++){ 
                      //  Read a row of data into an array
                      $rowData = $sheet-&gt;rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE);
                      //Insert into database
              }
          }
          else{
              echo "Please upload an XLSX or ODS file";
          }
      }
      else{
          echo $_FILES['spreadsheet']['error'];
      }
  }
  }
  
  ?&gt;
  </code></pre>