Route.path("form", form);
```
二、程式
program.gs
```
function form(e) {
var formData = {};
formData.webTitle = SCRIPT_PROP.getProperty("webTitle");//網站標題
formData.link = ScriptApp.getService().getUrl() ;
formData.adminEmail = SCRIPT_PROP.getProperty("adminEmail");//管理員email
formData.userEmail = Session.getActiveUser().getEmail();//訪客email,只能抓到擁有者
return render("form",{formData:formData});
}
```
三、樣板
form.html
```
formData.webTitle ?>
資料搜尋中....
```
四、程式
program.gs
```
/*==============================================
從form.html 樣板而來
回傳html 至 樣板
==============================================*/
function formDataInsert(formData){
//取得檔案
var ss = SpreadsheetApp.openById(SCRIPT_PROP.getProperty("id"));
var ws = ss.getSheetByName("成績表");
var mainTitle = ws.getRange(1, 1, 1, ws.getLastColumn()).getValues()[0];//取得成績表中文欄名
//判斷密碼是否正確
if(formData.pass != SCRIPT_PROP.getProperty("pass")){
var mains = []; //
}else{
var mains = ws.getSheetValues(2,1,ws.getLastRow()-1,ws.getLastColumn()); //
}
formData.webTitle = SCRIPT_PROP.getProperty("webTitle");//網站標題
formData.link = ScriptApp.getService().getUrl() ;
//顯示查詢結果
var all_search = HtmlService.createTemplateFromFile("all_search");
all_search.mainTitle = mainTitle;
all_search.mains = mains;
all_search.formData = formData;
var html = all_search.evaluate().getContent();//組合樣板與變數
return html;
}
```
五、樣板
all\_search.html
```
if(mains.length == 0){ ?>
}else {?>
} ?>
```