Ejemplo n.º 1
0
 /**
  * Returns the content of all cells as an associative array, indexed
  * off the cell location  (ie 'A1', 'D4', etc).  Each element of
  * the array is an associative array with a 'value' and a 'function'.
  * Only non-empty cells are returned by default.  'range' is the
  * value of the 'range' query parameter specified at:
  * http://code.google.com/apis/spreadsheets/reference.html#cells_Parameters
  *
  * @param mixed $location A CellQuery, WorksheetEntry or a URL (w/o query string) specifying the feed location.
  * @param string $range The range of cells to retrieve
  * @param boolean $empty Whether to retrieve empty cells
  * @return array An associative array of cells
  */
 public function getSpreadsheetCellFeedContents($location, $range = null, $empty = false)
 {
     $cellQuery = null;
     if ($location instanceof Zend_Gdata_Spreadsheets_CellQuery) {
         $cellQuery = $location;
     } else {
         if ($location instanceof Zend_Gdata_Spreadsheets_WorksheetEntry) {
             $url = $location->getLink(self::CELL_FEED_LINK_URI)->href;
             $cellQuery = new Zend_Gdata_Spreadsheets_CellQuery($url);
         } else {
             $url = $location;
             $cellQuery = new Zend_Gdata_Spreadsheets_CellQuery($url);
         }
     }
     if ($range != null) {
         $cellQuery->setRange($range);
     }
     $cellQuery->setReturnEmpty($empty);
     $cellFeed = $this->getCellFeed($cellQuery);
     $cellFeed = $this->retrieveAllEntriesForFeed($cellFeed);
     $spreadsheetContents = array();
     foreach ($cellFeed as $cellEntry) {
         $cellContents = array();
         $cell = $cellEntry->getCell();
         $cellContents['formula'] = $cell->getInputValue();
         $cellContents['value'] = $cell->getText();
         $spreadsheetContents[$cellEntry->getTitle()->getText()] = $cellContents;
     }
     return $spreadsheetContents;
 }