/**
* write 2D data into sheet.
* @example
* sheet.__proto__ = app.sheetPrototype
* sheet.setValues(data)
*/
app.sheetPrototype = {
// 🔸 sheet.setValues(data)
setValues(data, row=1, col=1){
if(!data || data.length === 0 || !data[0] || data[0].length === 0)
throw new Error(`⛔️ app.sheetPrototype.setValues(): data 是空的,無法寫入試算表❗️`);
// 資料表的「列數」與「欄數」
let rows = data.length;
let cols = data[0].length;
// 寫入頁面
this
.getRange(row, col, rows, cols)
.setValues(data);
return this; // for chaining
},
};