Writing spreadsheet function via code

坚强是说给别人听的谎言 提交于 2019-12-12 05:29:55

问题


I want to write this into the range B1..

=split(A1," ")

(the delimiter is a space)

How do I do it using code?

I tried this...

 var splitCell = "=SPLIT(A1," ")";
 SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1").getRange("B1").setFormula(splitCell);

But the quotes are obviously ruinous. Therefore how are quotes handled in such instances?


EDIT

Sorry. Brain-fart.

var splitCell = '=SPLIT(A8," ")';

I thought that I had already tried that (about a million times) but when I just tried it (again) it worked no problem.

Thanks anyway

(I'm sure I'll be back with less smelly questions in the future)


回答1:


At the time that I asked my question, I was not allowed to answer my own question (newbies here have limitations). However the answer to my question was stated in the "edited" part of my question.

I apologize for the confusion, but at the time I had no other options available to me, so therefore my question remained "Unanswered" even though I already resolved it.

Anyway, the answer is: var splitCell = '=SPLIT(A8," ")';



来源:https://stackoverflow.com/questions/15991896/writing-spreadsheet-function-via-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!