使用PHP的Google电子表格API v4 - 如何在开头插入空行

Tom*_*sek 4 php google-spreadsheet-api google-api-php-client

我对新的Google表格API v4感到困惑.我的问题是:如何在电子表格的开头插入一行?

我找不到任何有用的新Google Sheet API v4教程,也没有找到特定于PHP的Google可行文档.

Tom*_*sek 6

我懂了,

$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);
Run Code Online (Sandbox Code Playgroud)

其中$ this-> service是Google_Service_Sheets的实例,$ this-> sheetID是来自google docs url的SheetID

  • 我弄错了.我通过不使用类`Google_Service_Sheets_Request`并直接将请求体添加到`Google_Service_Sheets_BatchUpdateSpreadsheetRequest的`requests`参数来实现它. (2认同)