问题
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