-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathData JSON Data
More file actions
18 lines (18 loc) · 784 Bytes
/
Data JSON Data
File metadata and controls
18 lines (18 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function fetchDataFromAPI3() {
// Assuming SHEETID is defined elsewhere as the actual ID of your sheet
const sheetName = 'data'; // The name of your sheet tab
// Predefined data
const predefinedData = [
["1", "Leanne Graham", "Bret", "[email protected]"],
["2", "Ervin Howell", "Antonette", "[email protected]"]
];
// Headers
const headers = ['ID', 'Name', 'Username', 'Email'];
// Reference the sheet
const sheet = SpreadsheetApp.openById(SHEETID).getSheetByName(sheetName);
sheet.clear(); // Clear existing contents
// Set headers
sheet.getRange(1, 1, 1, headers.length).setValues([headers]);
// Set data (accounting for headers, start from row 2)
sheet.getRange(2, 1, predefinedData.length, predefinedData[0].length).setValues(predefinedData);
}