【问题标题】:How to get Google spreadsheet chart with Zend Gdata如何使用 Zend Gdata 获取 Google 电子表格图表
【发布时间】:2015-05-20 14:40:36
【问题描述】:

我正在使用 Zend Gdata 服务通过身份验证访问 Google 电子表格详细信息

我的电子表格有单元格数据和谷歌图表,我正确获取单元格数据但没有得到图表

让我知道我应该如何实现这一目标

我已经写了下面的代码

    $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
    $client = Zend_Gdata_ClientLogin::getHttpClient('EMAILADDRESS', 'PASSWORD', $service);
    $spreadsheetService = new Zend_Gdata_Spreadsheets($client);

    $spreadsheetKey = 'SPREADSHEETKEY';
    $query = new Zend_Gdata_Spreadsheets_DocumentQuery();
    $query->setSpreadsheetKey($spreadsheetKey);
    $feed = $spreadsheetService->getWorksheetFeed($query);

    $query = new Zend_Gdata_Spreadsheets_CellQuery();
    $query->setSpreadsheetKey($spreadsheetKey);
    $worksheetId = basename($feed->entries[0]->id);
    $query->setWorksheetId($worksheetId);


    if ($this->getRequest()->isPost()) {
        $cellFeed = $spreadsheetService->getCellFeed($query);
        $formdata = $this->getRequest()->getPost();
        foreach ($cellFeed as $cellEntry) {
            $row = $cellEntry->cell->getRow();
            $col = $cellEntry->cell->getColumn();
            $val = $cellEntry->cell->getText();
            $updatedCell = $spreadsheetService->updateCell($row, $col, $formdata['txtUpdate'], $spreadsheetKey, $worksheetId);
        }
    }

    $cellFeed = $spreadsheetService->getCellFeed($query);
    $totalCol = 0;
    foreach ($cellFeed as $cellEntry) {
        $row = $cellEntry->cell->getRow();
        $col = $cellEntry->cell->getColumn();
        $val = $cellEntry->cell->getText();
        $arrData[] = array('row' => $row, 'col' => $col, 'val' => $val);
        $arrDataNew[$row][] = array('col' => $col, 'val' => $val);
        if ($col > $totalCol) {
            $totalCol = $col;
        }
    }

我在互联网上搜索了有关通过 PHP 访问 Google 图表的信息,但没有得到任何帮助。让我知道我们是否可以通过 Zend 或普通 PHP 实现这一点也可以

【问题讨论】:

  • 谁做过markdown,告诉我为什么?我们不能做到这一点吗?
  • Google-apps-script 会这样做developers.google.com/chart/interactive/docs/spreadsheets 但是是否有用于 gdata 的“图表”api? Spreadsheet-API 中没有任何东西可以访问图表类型信息。

标签: php zend-framework google-spreadsheet-api


【解决方案1】:

zend gdata 使用 google 电子表格 api,您发现它只支持在行或单元格级别检索数据。您无法获得其他任何东西(图表、图像等)

只有谷歌应用程序脚本允许您get at the sheet charts (api)。如果您必须将其与其他内容集成,请将应用程序脚本内容服务发布为公开和匿名访问 请注意,并非所有图表类型都受支持。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-05
    • 2011-02-04
    • 1970-01-01
    • 2012-05-02
    • 2012-05-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多