我在Google表格中有此功能。目前我必須在字段中輸入=loadOutposts()
來觸發它。觸發Google表格函數寫入單元格
我已經在函數上設置了時間觸發器,但它沒有寫入數據到我的工作表。因爲我沒有在要寫入的函數中聲明表單和字段。如何讓函數將數據寫入Sheet2 A2而不必在該字段中輸入=loadOutposts()
?
Thx!
function loadOutposts(){
var outposts= new Array();
var url = "https://api.eveonline.com/eve/ConquerableStationList.xml.aspx";
var parameters = {method : "get", payload : ""};
var xmlFeed = UrlFetchApp.fetch(url, parameters).getContentText();
var xml = XmlService.parse(xmlFeed);
if(xml) {
var rows=xml.getRootElement().getChild("result").getChild("rowset").getChildren("row");
for(var i = 0; i < rows.length; i++) {
outpost=[rows[i].getAttribute("stationID").getValue(),
rows[i].getAttribute("stationName").getValue(),
rows[i].getAttribute("stationTypeID").getValue(),
rows[i].getAttribute("solarSystemID").getValue(),
rows[i].getAttribute("corporationID").getValue(),
rows[i].getAttribute("corporationName").getValue()
]
outposts.push(outpost);
}
}
return outposts;
}
感謝;)運行完美! – user6079228
你可能知道以下答案: 當我再次運行該函數時,它現在用它檢索的新數據替換Sheet2上的所有數據。 但是,可以根據stationID和stationTypeID的組合檢查新數據中是否有新行,並將新行添加到工作表2的頂部?那麼它不會替換所有的數據只添加新行? – user6079228