我试过下面的代码在电子表格内创建新工作表,但无法正常工作。
$service = new Google_Service_Sheets($client);
//pr($service);
$spreadsheetId = ‘You spredsheet id’;
$json_request_string = ‘{“requests”:[{“addSheet”: {“properties”: {“title”: “Project tasks”}}}]}’;
//$requests = json_decode($json_request_string);
// TODO: Assign values to desired properties of `requestBody`:
$requestBody = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest();
$requestBody->setRequests($json_request_string);
$response = $service->spreadsheets->batchUpdate($spreadsheetId, $requestBody);
我收到此错误:
请求包含无效的身份验证凭据错误
$title = "my new sheet";
//Create New Sheet
$body = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest(array(
'requests' => array('addSheet' => array('properties' => array('title' => $title )))));
$result = $service->spreadsheets->batchUpdate(SHEET_ID,$body);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句