title: Convert XLSX to JSON
body: <p>I am writing a script to basically convert an excel file to JSON.  The file is a giant budget with hundreds of lines.  I used the PHPExcel library to convert the xlsx file into a csv.  I then converted the excel file into a json, but am receiving an error:</p>
  
  <p><strong><em>Warning: array_combine(): Both parameters should have an equal number of elements</em></strong></p>
  
  <p>Here is my code</p>
  
  <pre><code>&lt;?php
  
  ini_set('memory_limit', '1000M');
  
  require_once 'classes/PHPExcel/IOFactory.php';
  
  $excel = PHPExcel_IOFactory::load("sap.xlsx");
  $writer = PHPExcel_IOFactory::createWriter($excel, 'CSV');
  $writer-&gt;setDelimiter(",");
  $writer-&gt;setEnclosure("");
  $writer-&gt;setLineEnding("\r\n");
  $writer-&gt;setSheetIndex(0);
  $writer-&gt;save("sap.csv");
  
  
  function getJsonFromCsv($file,$delimiter) { 
      if (($handle = fopen($file, 'r')) === false) {
          die('Error opening file');
      }
  
      $headers = fgetcsv($handle, 4000, $delimiter);
      $csv2json = array();
  
      while ($row = fgetcsv($handle, 4000, $delimiter)) {
        $csv2json[] = array_combine($headers, $row);
      }
  
      fclose($handle);
      return json_encode($csv2json); 
  }
  
  $file = 'sap.csv';
  echo getJsonFromCsv($file, ',');
  </code></pre>
  
  <p>What do I need to do to make this work?  Or really just convert a large xlsx file to JSON..</p>
  
  <p>Thanks</p>