问题
I am getting this error: "Missing ) after argument list. (line 8, file "Code")" When I run my code.
I've tried to switch around the single quotes around ProfileNav-value to double quotes and that did not work either. When I paste the exact function in line 8 into a shoot sheet cell, it works but google scripts does not let me run it.
function daily() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheetByName("BT");
sh.insertRowAfter(2);
sh.getRange("A3").setFormula('=TODAY()');
sh.getRange("D3").setFormula('=VALUE(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(JOIN("",REGEXEXTRACT(LOWER(SUBSTITUTE(INDEX(IMPORTXML(C1,"//@content"),2),",",)),"(\\d*\\.*\\d+)([km]*)")),"\\.",),"k","00"),"m","00000"))');
sh.getRange("E3").setFormula('=(D3-D4)/D3');
sh.getRange("B3").setFormula('=query(IMPORTXML($D$1,"//span[@class='ProfileNav-value']/@data-count"),"limit 1 offset 2")');
sh.getRange("C3").setFormula('=(B3-B4)/B3');
}
Looking for a way for line 8 to work.
回答1:
You need to escape the single quotation marks. This is done with a \
.
sh.getRange("B3").setFormula('=query(IMPORTXML($D$1,"//span[@class=\'ProfileNav-value\']/@data-count"),"limit 1 offset 2")');
回答2:
You'll need to escape the single quotes in this by putting a \
in front of each of them:
sh.getRange("B3").setFormula('=query(IMPORTXML($D$1,"//span[@class=\'ProfileNav-value\']/@data-count"),"limit 1 offset 2")');
来源:https://stackoverflow.com/questions/55507287/getting-error-missing-after-argument-list-line-8-file-code