title: XLS (All sheets) TO CSV With PHP
body: <p>Following is my php code that is reading .xls file and converting it into .csv.
  Script is working perfectly fine but the problem i am facing is that it is only working for one by default sheet. What I have been trying to do is that following script should get modified in a way that it reads data from all sheets present in .xls file and then save the output to data.csv. Kindly let me know how can I do that.</p>
  
  <p>Thanks,</p>
  
  <p>I am using following library:</p>
  
  <p><a href="http://sourceforge.net/projects/phpexcelreader/" rel="nofollow">http://sourceforge.net/projects/phpexcelreader/</a></p>
  
  <pre><code>  require_once 'lib/reader.php';
      $excel = new Spreadsheet_Excel_Reader();
      $excel-&gt;setOutputEncoding('CP1251');
      $excel-&gt;read('Student.xls');
      $x=1;
      $sep = ",";
      ob_start();
      while($x&lt;=$excel-&gt;sheets[0]['numRows']) {
       $y=1;
       $row="";
       while($y&lt;=$excel-&gt;sheets[0]['numCols']) {
           $cell = isset($excel-&gt;sheets[0]['cells'][$x][$y]) ? $excel-&gt;sheets[0]['cells'][$x][$y] : '';
           $row.=($row=="")?"\"".$cell."\"":"".$sep."\"".$cell."\"";
           $y++;
       } 
       echo $row."\n"; 
       $x++;
      }
      $fp = fopen("data.csv",'a');
      fwrite($fp,ob_get_contents());
      fclose($fp);
      ob_end_clean();
  echo "CSV file created successfully";
  </code></pre>