Source for file example.php

Documentation is available at example.php

  1. <?php
  2. require_once 'Excel/reader.php';
  3.  
  4.  
  5. // ExcelFile($filename, $encoding);
  6. $data new Spreadsheet_Excel_Reader();
  7.  
  8.  
  9. // Set output Encoding.
  10. //$data->setOutputEncoding('CP1251');
  11.  
  12. /***
  13. *  Some function for formatting output.
  14. * $data->setDefaultFormat('%.2f');
  15. * setDefaultFormat - set format for columns with unknown formatting
  16. *
  17. * $data->setColumnFormat(4, '%.3f');
  18. * setColumnFormat - set format for column (apply only to number fields)
  19. *
  20. **/
  21.  
  22.  
  23. $data->read('testfile.xls');
  24.  
  25. /*
  26.  
  27.  
  28.  $data->sheets[0]['numRows'] - count rows
  29.  $data->sheets[0]['numCols'] - count columns
  30.  $data->sheets[0]['cells'][$i][$j] - data from $i-row $j-column
  31.  
  32.  $data->sheets[0]['cellsInfo'][$i][$j] - extended info about cell
  33.     
  34.     $data->sheets[0]['cellsInfo'][$i][$j]['type'] = "date" | "number" | "unknown"
  35.         if 'type' == "unknown" - use 'raw' value, because  cell contain value with format '0.00';
  36.     $data->sheets[0]['cellsInfo'][$i][$j]['raw'] = value if cell without format 
  37.     $data->sheets[0]['cellsInfo'][$i][$j]['colspan'] 
  38.     $data->sheets[0]['cellsInfo'][$i][$j]['rowspan'] 
  39. */
  40. //echo 'start';
  41.  
  42. for ($i 1$i <= $data->sheets[0]['numRows']$i++{
  43.     for ($j 1$j <= $data->sheets[0]['numCols']$j++{
  44.         echo "\"".$data->sheets[0]['cells'][$i][$j]."\",";
  45.     }
  46.     echo "\n";
  47.  
  48. }
  49.  
  50.  
  51. //print_r($data);
  52. //print_r($data->formatRecords);
  53. ?>

Documentation generated on Thu, 08 Jan 2009 17:44:06 +0100 by phpDocumentor 1.4.0a2