S
S
Shamil Khairulaev2022-02-04 17:39:46
PHP
Shamil Khairulaev, 2022-02-04 17:39:46

How to update second sheet in google sheets api?

I am using google sheets api to work with google sheets and I need to change the second sheet.

Here I add rows to the sheet, which is the default

public function addRows ($values, $range = 'A1')
    {
        $body = new Google_Service_Sheets_ValueRange(['values' => $values]);
        $opts = ['valueInputOption' => 'USER_ENTERED'];
        return $this->service->spreadsheets_values->update($this->doc_id, $range, $body, $opts);
    }


What do I need to add to change or add to change the sheet I want?
Thanks for your reply in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2022-02-17
@ComPUCKter

It is necessary to refer to the desired range, nanprmier, as @ProgrammerForever wrote. A feature of the API is that without specifying the sheet name, it is assumed that the work is done with the first sheet by index. In interfaces, this sheet is the same as the first tab.
$range = 'Лист2!A1'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question