I'm trying to update a given spreadsheet cell, using node.js googleapis v4 and authorizing with a JWT client.
Reading works fine, but I cannot understand how to write:
new Promise((resolve, reject) => {
sheets.spreadsheets.values.update({
auth: this._auth,
spreadsheetId: this._metaData.spreadSheetId,
range: range,
valueInputOption: 'USER_ENTERED'
},(err, resp) => {
if (err) {
console.log('Data Error :', err)
reject(err);
}
resolve(resp);
});
});
How do I specify the data, and how do I pass it to the call?
I understand I should use a ValueRange object, but how?
Visit Google Sheets and open the spreadsheet where you want to locate and update your data. Click Edit > Find and Replace from the menu. When the Find and Replace window displays, enter the data you want to locate in the Find box. Then, in the Replace With box, enter what you want to update it with.
Once you've set up your API to Google Sheets connection, click Save And Run to get data to your spreadsheet.
After better reviewing the (poor) documentation, I inferred that you had to pass a request object in the call:
return new Promise((resolve, reject) => {
sheets.spreadsheets.values.update(
{
auth: this._auth,
spreadsheetId: this._metaData.spreadSheetId,
range: range,
valueInputOption: "USER_ENTERED",
resource: { range: "Sheet1!A1", majorDimension: "ROWS", values: [["b"]] },
},
(err, resp) => {
if (err) {
console.log("Data Error :", err);
reject(err);
}
resolve(resp);
}
);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With