实际上,我有两个关于查询功能的问题: 1)如何将我的ActiveSpreadsheet中的数组(如数据源)分配到Query中?可能吗? 当我尝试这样做时,如下所述: https://developers.google.com/chart/interactive/docs/querylanguage#Using_the_Query_Language
var uniqueAddrs = new google.visualization.Query("http://spreadsheets.google.com/a/google.com/tq?key=14msARLVvH5I17UIncJrx1JDTTtAKKDXTrF436SEe4rI")
调试器告诉我" google"对象未定义。当我尝试在URL末尾添加一个Query请求时,我有同样的响应,当然是编码的(例如" http ... someurl ..& tq = select%20A%2C%20sum(B)%20group %20by%20A&#34)
2)如何追求"查询了解UTF-8(西里尔符号)?有可能吗?
答案 0 :(得分:1)
我编写了我自己的query()和unique()函数。这并不像我想象的那么困难。也许,对某人有用: 唯一函数(返回数组中的唯一行):
function getUnique(array){
var uniqVals = new Array;
for(i in array){
var duplicate = 0;
for(n in uniqVals){
if(array[i].join() === uniqVals[n].join()){
duplicate ++;
}
}
if(duplicate === 0){
uniqVals.push(array[i])
}
}
return uniqVals
}
改进了Vlookup功能。可以从所需列返回一个值,该列与3个不同列中的3个条件匹配。轻松添加更多标准:
function vlp3(array,resultColumn,
criterion1,criteriaColumn1,
criterion2,criteriaColumn2,
criterion3,criteriaColumn3){
var matchVals = new Array;
for(i in array){
// var match = 0;
if(criterion1 === array[i][criteriaColumn1] &&
criterion2 === array[i][criteriaColumn2] &&
criterion3 === array[i][criteriaColumn3]){
matchVals.push([array[i][resultColumn],""]); //error arise without second element("") in row when trying getUnique it. Has no .join()method for single elements
}
}
return matchVals
}