Santosh S Kumar Santosh S Kumar - 2 months ago 49
PHP Question

Google sheets API 4: How to append to the end of the row

Able to update the row by providing the range, here is the code:

$range = "A1:B1";
$valueRange= new Google_Service_Sheets_ValueRange();
$valueRange->setValues(["values" => ["a", "b"]]);
$conf = ["valueInputOption" => "RAW"];
$service->spreadsheets_values->update($spreadsheetId, $range, $valueRange, $conf);


Considering I don't know the range, how can I insert the row to the end of the sheet.

Answer

Are you looking for spreadsheets.values.append? The guide for example usage is here.

The reference docs for append describe it as: Appends values to a spreadsheet. The input range is used to search for existing data and find a "table" within that range. Values will be appended to the next row of the table, starting with the first column of the table. See the guide and sample code for specific details of how tables are detected and data is appended.

If that's not what you're looking for, can you be more specific with your question?