12-1-1
Google表單購物車 功能加強
Google表單
- 請先用預覽,增加幾筆資料
Google試算表
- 標題列在「訂購商品」後面增加「單價」、「數量」、「小計」
- 此三欄的格式為靠右對齊
- 試算表 A欄的索引值為 1 、B欄的索引值為2 、C欄的索引值為3 .......依此類推
- 試算表 1列的索引值為 1 、2列的索引值為2 、3列的索引值為3 .......依此類推
Google Apps Script
- 指令
- 函式 function(參數1, 參數2 ......){
許多指令
}
- 變數、常數宣告
var :全域變數
let :範圍變數
const:常數,宣告後,其值即固定。例圓周率 const x = 3.14159265359
Apps Script 指令
- 試算表app:SpreadsheetApp
- 取得試算表:SpreadsheetApp.getActiveSpreadsheet();
- 取得工作表:SpreadsheetApp.getActiveSpreadsheet().getSheetByName(工作表名);
function test(){
let ss = SpreadsheetApp.getActiveSpreadsheet();
let ws = ss.getSheetByName('表單回應 1');
}
- 取得工作表範圍資料:ws.getSheetValues(列起始編號, 欄起始編號, 列的數量, 欄的數量);
- 印出資料:console.log()
- 資料型態:文字、數字、陣列、物件.....
- 陣列的索引:從 0開始
- 工作表最後的欄索引:ws.getLastColumn()
- 工作表最後的列索引:ws.getLastRow()
