2016-06-14 115 views

回答

4

我得到這個,

$requests = new Google_Service_Sheets_Request(array(
    'insertDimension' => array(
     'range' => array(
      'sheetId' => 0, 
      'dimension' => "ROWS", 
      'startIndex' => 1, 
      'endIndex' => 2 
     ) 
    ) 
)); 


$batchUpdateRequest = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest(array(
    'requests' => $requests 
)); 


$this->service->spreadsheets->batchUpdate($this->sheetID, $batchUpdateRequest); 

其中$這個 - >服務Google_Service_Sheets的實例,$這個 - > sheetID是從谷歌文檔的URL您SheetID

+0

我得到這個錯誤。我通過不使用類「Google_Service_Sheets_Request」直接將請求主體添加到「Google_Service_Sheets_BatchUpdateSpreadsheetRequest」的「requests」參數 –

0

這是我如何做的:

//Insert blank new row between R1 and R2 (there is no R0) 
$dr = new Google_Service_Sheets_DimensionRange(); 
$dr->setSheetId(0);//first sheet/tab of spreadsheet file 
$dr->setDimension('ROWS'); 
$dr->setStartIndex(1); 
$dr->setEndIndex(2); 
$ins = new Google_Service_Sheets_InsertDimensionRequest(); 
$ins->setRange($dr); 
$ins->setInheritFromBefore(false); 
$ssr = new Google_Service_Sheets_Request(); 
$ssr->setInsertDimension($ins); 
$busr = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest(); 
$busr->setRequests([$ssr]); 
$response = $sheetsService->spreadsheets->batchUpdate($spreadsheetId, $busr, []); 
相關問題