Reading Google docs spreadsheet

2019-03-31 00:57发布

Is it possible to pull rows from a Google Docs spreadsheet using PHP?

In SQL I would use something like:

SELECT * FROM table WHERE field = 'value' LIMIT 1

Is there a way to do this? I've heard you are supposed to use a 'Zend' framework, but I haven't been able to figure that out either. Any help would be appreciated

2条回答
成全新的幸福
2楼-- · 2019-03-31 01:19

From the Zend_Gdata documentation:

<?php
  $query = new Zend_Gdata_Spreadsheets_ListQuery();
  $query->setSpreadsheetKey($spreadsheetKey);
  $query->setWorksheetId($worksheetId);
  $query->setSpreadsheetQuery('name=John and age>25');
  $listFeed = $spreadsheetService->getListFeed($query);
?>

And to setup the $spreadsheetService object:

<?php
  $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
  $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
  $spreadsheetService = new Zend_Gdata_Spreadsheets($client);
  $feed = $spreadsheetService->getSpreadsheetFeed();
?>

You'll need to download either the full Zend Framework, or the standalone Google Data library.

查看更多
可以哭但决不认输i
3楼-- · 2019-03-31 01:24

What you're looking for is the Google Visualization API Query Language

No need for PHP middleware to get it working. It's already built-in to docs.

Here's a brief introduction tutorial to help get you started.

It's a SQL-like syntax that works by sending the query through a parameterized URI. It can return the matching data in JSON, CSV, or a HTML Table. It's still really new and has a few quirks so be sure to read through all the comments on the second link I posted.

查看更多
登录 后发表回答