Parse error from using .setValue or .SetFormula to set a formula containing a query function that has multiple single and double quotes

前端 未结 1 604
甜味超标
甜味超标 2020-12-22 05:29

I have a formula in sheet A using new google sheets that works fine; it contains a query function that filters the dates based on values in sheet B(\'Settings\') and data in

1条回答
  •  庸人自扰
    2020-12-22 06:03

    Too easy! instead of '+ just use \ to escape the single quotes in my formula so answer is: range.setFormula('=QUERY(Data!A1:G,"select G, sum(E) where F is not null AND toDate(D)>= date \'" & text(\'Settings\'!B5, "yyyy-MM-dd")&"\' and toDate(D)<= date \'" & text(\'Settings\'!B6, "yyyy-MM-dd")&"\'group by G pivot B label G\'Pivot table for data in range\'")\');

    0 讨论(0)
提交回复
热议问题