gdatazend-gdatagoogle-sheets-api

Zend GData Spreadsheet WorksheetID


What is the $worksheetId from the Zend GData documentation supposed to be?

http://framework.zend.com/manual/en/zend.gdata.spreadsheets.html

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

The documentation uses that $worksheetId several times, but I can't seem to see where to get that from a spreadsheet.


Solution

  • If you don't know the worksheet identifiers, you have to perform a first query to retrieve the worksheets metafeed for your spreadsheet:

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

    Then, you iterate $feed->entries and each entry will represent a worksheet and have an identifier.