如何通过php中的特定值从Google电子表格中获取数据?

时间:2016-03-08 06:28:12

标签: php excel google-sheets

我正试图通过某些特定值从Google电子表格中获取数据,目前我尝试了以下方法:

 $spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
 $spreadsheetFeed = $spreadsheetService->getSpreadsheets();
 $spreadsheet = $spreadsheetFeed->getByTitle(APPLICATION_GOOGLE_SPREADSHEETS_BOOK);
 $worksheetFeed = $spreadsheet->getWorksheets();
 $worksheet = $worksheetFeed->getByTitle(APPLICATION_GOOGLE_SPREADSHEETS_SHEET);

我使用它时工作正常:

$listFeed = $worksheet->getListFeed(array("sq" => "name = henryhwong", "reverse" => "true"));

但是当它对电子邮件执行相同操作时会出错:

$listFeed = $worksheet->getListFeed(array("sq" => "email = henryhwong@gmail.com", "reverse" => "true"));

错误是因为" @",如果搜索其他任何不包含" @"然后它完美地运作,我无法找到原因。

2 个答案:

答案 0 :(得分:0)

之前有过类似的问题。尝试将电子邮件用双引号括起来:

$listFeed = $worksheet->getListFeed(array("sq" => 'email = "henryhwong@gmail.com"', "reverse" => "true"));

答案 1 :(得分:0)

请尝试以下代码。希望它可以帮到你。

$listFeed = $worksheet->getListFeed(array("sq" => "email" = "henryhwong@gmail.com", "reverse" => "true"));