Tomas Lysek Tomas Lysek - 2 months ago 57x
PHP Question

Google spreadsheet API v4 with PHP - hot to insert empty row to beginning

I am confused about the new Google Sheets API v4.
My question is: how can I insert a row to the beginning of the spreadsheet?

I can't find any useful tutorial for the new Google Sheet API v4 or find viable documentation from Google specific to PHP.


I got this,

$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);

where $this->service is instance of Google_Service_Sheets and $this->sheetID is your SheetID from google docs url