12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- $erCalc_Reader = error_reporting(E_ALL | E_STRICT);
- class Calc_Reader
- {
- const NS_TABLE = "urn:oasis:names:tc:opendocument:xmlns:table:1.0";
- const NS_OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0";
-
- public $xml;
-
- public $xpath;
- function __construct($path)
- {
- $this->xml = new DOMDocument();
- $this->xml->preserveWhiteSpace = FALSE;
- $this->xml->load($path);
- $this->xpath = new DOMXPath($this->xml);
- $this->xpath->registerNameSpace('office', Calc_Reader::NS_OFFICE);
- $this->xpath->registerNameSpace('table', Calc_Reader::NS_TABLE);
- }
-
- function getCalcSheets()
- {
- $sq = '//table:table';
- $list = $this->xpath->query($sq);
- unset($sq);
- return $list;
- }
-
- function getCalcSheetNames()
- {
- $dnlSheets = $this->getCalcSheets();
- $ret = array();
- foreach ($dnlSheets as $node)
- {
- $ret[] = $node->getAttributeNS(Calc_Reader::NS_TABLE, 'name');
- }
- unset($dnlSheets);
- return $ret;
- }
-
- function getRows ($namedRange = NULL)
- {
- $query = empty($namedRange)
- ? '//table:table-row'
- : '//table:table[@table:name="' . $namedRange . '"]/table:table-row';
- $ret = $this->xpath->query($query);
- unset($query);
- return $ret;
- }
- }
- error_reporting($erCalc_Reader);
- unset ($erCalc_Reader);
|