8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
18 * @subpackage Spreadsheets
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
25 * @see Zend_Gdata_Entry
27 require_once 'Zend/Gdata/Entry.php';
30 * @see Zend_Gdata_Spreadsheets_Extension_RowCount
32 require_once 'Zend/Gdata/Spreadsheets/Extension/RowCount.php';
35 * @see Zend_Gdata_Spreadsheets_Extension_ColCount
37 require_once 'Zend/Gdata/Spreadsheets/Extension/ColCount.php';
40 * Concrete class for working with Worksheet entries.
44 * @subpackage Spreadsheets
45 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
46 * @license http://framework.zend.com/license/new-bsd New BSD License
48 class Zend_Gdata_Spreadsheets_WorksheetEntry extends Zend_Gdata_Entry
51 protected $_entryClassName = 'Zend_Gdata_Spreadsheets_WorksheetEntry';
53 protected $_rowCount = null;
54 protected $_colCount = null;
57 * Constructs a new Zend_Gdata_Spreadsheets_WorksheetEntry object.
59 * @param DOMElement $element (optional) The DOMElement on which to base this object.
61 public function __construct($element = null)
63 $this->registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces);
64 parent::__construct($element);
68 * Retrieves a DOMElement which corresponds to this element and all
69 * child properties. This is used to build an entry back into a DOM
70 * and eventually XML text for sending to the server upon updates, or
71 * for application storage/persistence.
73 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
74 * @return DOMElement The DOMElement representing this element and all
77 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
79 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
80 if ($this->_rowCount != null) {
81 $element->appendChild($this->_rowCount->getDOM($element->ownerDocument));
83 if ($this->_colCount != null) {
84 $element->appendChild($this->_colCount->getDOM($element->ownerDocument));
90 * Creates individual Entry objects of the appropriate type and
91 * stores them in the $_entry array based upon DOM data.
93 * @param DOMNode $child The DOMNode to process
95 protected function takeChildFromDOM($child)
97 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
98 switch ($absoluteNodeName) {
99 case $this->lookupNamespace('gs') . ':' . 'rowCount';
100 $rowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount();
101 $rowCount->transferFromDOM($child);
102 $this->_rowCount = $rowCount;
104 case $this->lookupNamespace('gs') . ':' . 'colCount';
105 $colCount = new Zend_Gdata_Spreadsheets_Extension_ColCount();
106 $colCount->transferFromDOM($child);
107 $this->_colCount = $colCount;
110 parent::takeChildFromDOM($child);
117 * Gets the row count for this entry.
119 * @return string The row count for the entry.
121 public function getRowCount()
123 return $this->_rowCount;
127 * Gets the column count for this entry.
129 * @return string The column count for the entry.
131 public function getColumnCount()
133 return $this->_colCount;
137 * Sets the row count for this entry.
139 * @param string $rowCount The new row count for the entry.
141 public function setRowCount($rowCount)
143 $this->_rowCount = $rowCount;
148 * Sets the column count for this entry.
150 * @param string $colCount The new column count for the entry.
152 public function setColumnCount($colCount)
154 $this->_colCount = $colCount;
159 * Returns the content of all rows as an associative array
161 * @return array An array of rows. Each element of the array is an associative array of data
163 public function getContentsAsRows()
165 $service = new Zend_Gdata_Spreadsheets($this->getHttpClient());
166 return $service->getSpreadsheetListFeedContents($this);
170 * Returns the content of all cells as an associative array, indexed
171 * off the cell location (ie 'A1', 'D4', etc). Each element of
172 * the array is an associative array with a 'value' and a 'function'.
173 * Only non-empty cells are returned by default. 'range' is the
174 * value of the 'range' query parameter specified at:
175 * http://code.google.com/apis/spreadsheets/reference.html#cells_Parameters
177 * @param string $range The range of cells to retrieve
178 * @param boolean $empty Whether to retrieve empty cells
179 * @return array An associative array of cells
181 public function getContentsAsCells($range = null, $empty = false)
183 $service = new Zend_Gdata_Spreadsheets($this->getHttpClient());
184 return $service->getSpreadsheetCellFeedContents($this, $range, $empty);