0
我想通過PHP/Zend腳本從Google電子表格中獲取所有行。這是我使用的腳本:PHP/Zend/Google Spreadsheet沒有得到所有行
$service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient('xxxxxxxxx', 'xxxxxxx', $service);
$spreadsheetService = new Zend_Gdata_Spreadsheets($client);
// Get spreadsheet key
$spreadsheetsKey = 'xxxxxxxxxxxxx';
$worksheetId = 'xxx';
// Get cell feed
$query = new Zend_Gdata_Spreadsheets_CellQuery();
$query->setSpreadsheetKey($spreadsheetsKey);
$query->setWorksheetId($worksheetId);
$cellFeed = $spreadsheetService->getCellFeed($query);
// Build an array of entries:
$ssRows = array();
$ssRow = array();
$titleRow = array();
$tableRow = 1;
foreach($cellFeed as $cellEntry) {
$row = $cellEntry->cell->getRow();
$col = $cellEntry->cell->getColumn();
$val = $cellEntry->cell->getText();
// Add each row as a new array:
if ($row != $tableRow) {
array_push($ssRows, $ssRow);
$ssRow = array();
// Move to the next row/new array
$tableRow = $row;
}
// Build the array of titles:
if ($row == 1) {
$titleRow[$col] = $val;
}
// Build the array of results with the title as the key:
else {
$key = $titleRow[$col];
$ssRow[$key] = $val;
}
}
// Pass the results array:
return array_reverse($ssRows);
這將構建我數組的大部分從電子表格中的細節,但它總是錯過了最後的條目 - 任何人都可以看到我做錯了,或者是有從電子表格中獲取所有數據的更好方法?
該表格是基於不同答案的3部分表格。在填寫一個部分時,我想要顯示一個URL到表單中,並從第一個表單中預先填充一些細節,以便更快地填寫表單的第二部分。這一切都很好,它只是缺少最後一項是主要問題!
謝謝!
D'oh似乎是一個明顯的答案,無法看到Forrest的樹!我試着得到一個列表提要,但似乎無法得到任何迴應,而且文檔非常薄!以下文檔中的示例不返回任何內容!當列表提要接受一個查詢時,這是一種痛苦,這意味着我可以選擇我得到的結果的年齡大小,而不是一切! – Scoobler