Calc_Reader.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Utility class to access OpenDocument spreadsheets read-only
  4. *
  5. * Requires PHP 5.0.3
  6. *
  7. * @version $Id: Calc_Reader.php,v 1.1 2005-02-27 10:58:44 marand Exp $
  8. * @license CeCILL 2.0
  9. * @copyright 2005 Ouest Systemes Informatiques
  10. */
  11. $erCalc_Reader = error_reporting(E_ALL | E_STRICT);
  12. /**
  13. * Utility class to access OpenDocument spreadsheets read-only
  14. */
  15. class Calc_Reader
  16. {
  17. const NS_TABLE = "urn:oasis:names:tc:opendocument:xmlns:table:1.0";
  18. const NS_OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0";
  19. /**
  20. * @var DOMDocument $xml
  21. */
  22. public $xml;
  23. /**
  24. * @var DOMXPath $xpath
  25. */
  26. public $xpath;
  27. function __construct($path)
  28. {
  29. $this->xml = new DOMDocument();
  30. $this->xml->preserveWhiteSpace = FALSE;
  31. $this->xml->load($path);
  32. $this->xpath = new DOMXPath($this->xml);
  33. $this->xpath->registerNameSpace('office', Calc_Reader::NS_OFFICE);
  34. $this->xpath->registerNameSpace('table', Calc_Reader::NS_TABLE);
  35. }
  36. /**
  37. * Return the rows in the spreadsheet as a DOMNodeList
  38. *
  39. * @return DOMNodeList
  40. */
  41. function getRows ()
  42. {
  43. $query = '//table:table-row';
  44. $ret = $this->xpath->query($query);
  45. unset($query);
  46. return $ret;
  47. }
  48. }
  49. error_reporting($erCalc_Reader);
  50. unset ($erCalc_Reader);