Пример #1
0
 /**
  * Retrieve a particular cell
  * @param	string								$st_id	Spreadsheet ID
  * @param	string								$wt_id	Worksheet ID
  * @return	Zend_Gdata_Spreadsheets_CellEntry	$entry	CellEntry object containing cell data
  */
 public function getCell($st_id, $wt_id, $cell_id)
 {
     $query = new Zend_Gdata_Spreadsheets_CellQuery();
     $query->setSpreadsheetKey($st_id);
     $query->setWorksheetId($wt_id);
     /*
      * Parse cell id
      */
     // min length is 4
     if (strlen($cell_id) < 4) {
         throw new Exception();
     }
     $matches = array();
     preg_match("/^R(\\d+)C(\\d+)\$/", $cell_id, $matches);
     $query->setMaxRow($matches[1])->setMinRow($matches[1])->setMaxCol($matches[2])->setMinCol($matches[2]);
     return $this->getFeed($query->getQueryUrl());
 }
Пример #2
0
 */
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
/**
 * @see Zend_Gdata_Spreadsheets
 */
Zend_Loader::loadClass('Zend_Gdata_Spreadsheets');
$authService = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
$httpClient = Zend_Gdata_ClientLogin::getHttpClient('*****@*****.**', 'internet21', $authService);
$gdClient = new Zend_Gdata_Spreadsheets($httpClient);
$query = new Zend_Gdata_Spreadsheets_CellQuery();
$query->setSpreadsheetKey('0AlkFQsJI6D_7dEZOVXlTeDNYOGsyNVNWalNLdWdDU2c');
$query->setWorksheetId(3);
$query->setMinCol(3);
$query->setMaxCol(3);
$query->setMinRow(17);
$query->setMaxRow(17);
$feed = $gdClient->getCellFeed($query);
$entry = $gdClient->updateCell(16, 4, $_GET['precio'], '0AlkFQsJI6D_7dEZOVXlTeDNYOGsyNVNWalNLdWdDU2c', 3);
$entry = $gdClient->updateCell(17, 4, $_GET['enganche'], '0AlkFQsJI6D_7dEZOVXlTeDNYOGsyNVNWalNLdWdDU2c', 3);
$entry = $gdClient->updateCell(13, 9, $_GET['anio'], '0AlkFQsJI6D_7dEZOVXlTeDNYOGsyNVNWalNLdWdDU2c', 3);
$entry = $gdClient->updateCell(13, 3, $_GET['marca'], '0AlkFQsJI6D_7dEZOVXlTeDNYOGsyNVNWalNLdWdDU2c', 3);
$entry = $gdClient->updateCell(14, 3, $_GET['linea'], '0AlkFQsJI6D_7dEZOVXlTeDNYOGsyNVNWalNLdWdDU2c', 3);
$i = 0;
foreach ($feed->entries as $entry) {
    if ($entry instanceof Zend_Gdata_Spreadsheets_CellEntry) {
        print "<div class=\"calc-item\"><label>Monto del enganche:</label> " . number_format($entry->content->text, 2) . "</div>";
    }
    $i++;
}
$query->setMinCol(5);
$query->setMaxCol(5);
Пример #3
0
function gdata_import($attrib)
{
    if ($attrib["key"] == "" || $attrib["worksheet"] == "" || $attrib["user"] == "" || $attrib["pass"] == "") {
        echo 'ERROR: SET ALL ATTRIBUTES i.e sheet, worksheet, user, pass and columns. ';
        return;
    }
    // load Zend Gdata libraries
    set_include_path(get_include_path() . PATH_SEPARATOR . WP_PLUGIN_DIR . "//gdata-importer//");
    require_once 'Zend/Loader.php';
    Zend_Loader::loadClass('Zend_Gdata_Spreadsheets');
    Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
    // set credentials for ClientLogin authentication
    $user = $attrib["user"];
    $pass = $attrib["pass"];
    try {
        // connect to API
        $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
        $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
        $service = new Zend_Gdata_Spreadsheets($client);
        // get spreadsheet entry
        $ssEntry = $service->getSpreadsheetEntry('https://spreadsheets.google.com/feeds/spreadsheets/' . $attrib["key"]);
        // get worksheets in this spreadsheet
        $wsFeed = $ssEntry->getWorksheets($attrib["worksheet"]);
    } catch (Exception $e) {
        echo 'ERROR: ' . $e->getMessage();
        return;
    }
    $content = <<<HTML
\t<table>
HTML;
    foreach ($wsFeed as $wsEntry) {
        if ($wsEntry->getTitle() == $attrib["worksheet"]) {
            //get title
            $query = new Zend_Gdata_Spreadsheets_CellQuery();
            $query->setSpreadsheetKey($attrib["key"]);
            $id = $wsEntry->getId();
            $arr = explode('/', $id);
            $query->setWorksheetId($arr[sizeof($arr) - 1]);
            $query->setMinRow(1);
            $query->setMaxRow(1);
            $cellFeed = $service->getCellFeed($query);
            $content = $content . "<tr>";
            foreach ($cellFeed as $cellEntry) {
                $content = $content . "<td>" . $cellEntry->getCell()->getText() . "</td>";
            }
            $content = $content . "</tr>";
            //get content
            $rows = $wsEntry->getContentsAsRows();
            foreach ($rows as $row) {
                $content = $content . "<tr>";
                foreach ($row as $key => $value) {
                    $content = $content . "<td>" . $value . "</td>";
                }
                $content = $content . "</tr>";
            }
        }
    }
    $content = $content . <<<HTML
\t\t</tbody>
\t</table>
HTML;
    return $content;
}