Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google spreadsheet API v4 with PHP - how 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.

like image 413
Tomas Lysek Avatar asked Jun 14 '16 15:06

Tomas Lysek


1 Answers

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

like image 179
Tomas Lysek Avatar answered Sep 17 '22 19:09

Tomas Lysek