У меня есть одноэлементный класс-оболочка (давайте посмотрим правде в глаза, они нужны большинству API Google PHP), экземпляром которого является мой клиентский класс
Код: Выделить всё
$gsheets
Код: Выделить всё
$newspreadsheetTitle="ABC123456";
$newdocument = $gsheets->newSpreadsheetDocument($newspreadsheetTitle);
Код: Выделить всё
public function newSpreadsheetDocument($title) {
$newspread = new Google_Service_Sheets_Spreadsheet([
'properties' => [
'title' => $title
]
]);
$newspread = $this->service->spreadsheets->create($newspread);
$id = $newspread->getSpreadsheetId();
return ["ID" => $newspread->getSpreadsheetId(), "url" => $newspread->getSpreadsheetUrl()];
}
Это демонстрирует, что
Код: Выделить всё
$this->service
Итак, теперь мой вопрос :
Затем я хочу скопировать содержимое (вся вкладка/лист) из этого шаблона в эту вновь созданную таблицу, поэтому я звоню
Код: Выделить всё
$gsheets->copySheetFromTo($POtemplateID, $newdocument["ID"], 0);
Код: Выделить всё
public function copySheetFromTo($sourceSpreadsheetFileId, $destinationSpreadsheetFileId, $sourceTabRef) {
$requestBody = new Google_Service_Sheets_CopySheetToAnotherSpreadsheetRequest();
$requestBody->setDestinationSpreadsheetId($destinationSpreadsheetFileId);
$response = $this->service->spreadsheets_sheets->copyTo($sourceSpreadsheetFileId, $sourceTabRef, $requestBody);
/*
$request = new Google_Service_Sheets_CopySheetToAnotherSpreadsheetRequest([
"destinationSpreadsheetId" => $toFileID
]);
$this->service->spreadsheets_sheets->copyTo($fromFileID, $fromTabName, $request);
*/
return $response;
}
Код: Выделить всё
$gsheets->copySheetFromTo($POtemplateID, $newdocument["ID"], 0);
Код: Выделить всё
The sheet (0) does not exist.
Код: Выделить всё
$gsheets->copySheetFromTo($POtemplateID, $newdocument["ID"], 1);
Код: Выделить всё
The sheet (1) does not exist.
Код: Выделить всё
$gsheets->copySheetFromTo($POtemplateID, $newdocument["ID"], "template_sheet");//the name of the sheet tab to copy
Код: Выделить всё
Invalid value at 'sheet_id' (TYPE_INT32), "template_sheet"
Подробнее здесь: https://stackoverflow.com/questions/791 ... to-another
Мобильная версия