我試圖通過匹配幾列來連接兩個工作表。我將它們都加載到我的腳本中,但後來我很確定我錯誤地使用了連接方法。我究竟做錯了什麼?使用google.visualisation.data.join和doGet() - ReferenceError:未定義「google」
這是整個代碼,部署爲一個Web應用程序。
function doGet() {
//get the first table
var mainsheet = SpreadsheetApp.openById('1pGxg4bEaoNzkL-JS22GO2-eo7K4UlxPNcjD4Na-6Eik').getSheetByName('Form Responses 1');
var maintable = mainsheet.getDataRange();
//get the second table
var subsetsheet = SpreadsheetApp.openById('1pGxg4bEaoNzkL-JS22GO2-eo7K4UlxPNcjD4Na-6Eik').getSheetByName('Latest Rows');
var subsettable = subsetsheet.getDataRange();
//join the tables - this is where i get the 'ReferenceError: "google" is not defined. ' error
var joinedtable = new google.visualisation.data.join(subsettable, maintable, 'left', [[0,1],[1,3],[2,4]],[],[2]);
//make a chart from the joined table for display
var joinedtablechart = Charts.newTableChart().setDataTable(joinedtable).build();
//display the joined table
var siteProfiles = UiApp.createApplication();
siteProfiles.add(joinedtablechart);
return siteProfiles;
}
這是領先的嗎?
Uncaught ReferenceError: google is not defined
謝謝指點!
感謝您的澄清。我遵循教程,它是有幫助的,並且據我看到我的代碼除了連接嘗試之外沒有問題。這是否意味着我將無法在腳本中使用google.visualisation.data.join? – Lukasz 2014-10-30 02:44:25
不,您將無法直接從UiApp代碼調用任何外部JavaScript服務。我已經添加到答案了......你需要做出自己的「加入」。 – Mogsdad 2014-10-30 11:35:16