I want to define a javascript variable with google spreadsheet value.
The Range is B2
It will be executed on wordpress site ..
First I want to define a variable with cell value .. And then I want to use that variable for innerHtml of
element.
I'm new to javascript.
Pls give the format of code and I will modify that code. with my spreadsheetId
Where do you want to execute your code to?
If you want to save a cell value as a variable, you need to use Google Apps Script:
var cellValue = SpreadsheetApp.getActiveSheet().getRange('B2').getValue();
After that you can use your variable in your Apps Script code.
If you're using the NodeJS library, you need to read the file using a async function with some methods:
const sheets = google.sheets({version: 'v4', auth});
sheets.spreadsheets.values.get({
spreadsheetId: 'ID',
range: 'Sheet Name!range',
}
For more info visit the documentation on: https://googleapis.dev/nodejs/googleapis/latest/sheets/classes/Resource$Spreadsheets.html