Sunday, May 19, 2024
24
rated 0 times [  30] [ 6]  / answers: 1 / hits: 16010  / 11 Years ago, fri, july 12, 2013, 12:00:00

I have recently started writing some scripts for Google Spreadsheets. I have no experience with Javascript though and I have question that is concerning a (as I suppose) basic issue.



I would like my script to insert data shown below into a cell in a sheet. How should I encode it to make it work?



komorkaLinku.setValue(=HYPERLINK(http://www.some.link/some/data+variable+something,something));


I had tried several ways but none of them worked.


More From » google-apps-script

 Answers
11

You are trying to include quotes inside quoted text. There are a couple of ways to do that.




  1. Use single quotes inside double quotes, or vice-versa.



    komorkaLinku.setValue('=HYPERLINK(http://www.some.link/some/data'+variable+'something,something)');

  2. Use escaped single quotes.



    komorkaLinku.setValue('=HYPERLINK('http://www.some.link/some/data'+variable+''something','something')');



As @ScampMichael comments, it would be a better choice to use setFormula() in this case. You would still need to handle embedded quotes properly.


[#77034] Thursday, July 11, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
blaisep

Total Points: 748
Total Questions: 95
Total Answers: 108

Location: Federated States of Micronesia
Member since Sun, May 16, 2021
3 Years ago
blaisep questions
Wed, Dec 16, 20, 00:00, 4 Years ago
Sun, Aug 16, 20, 00:00, 4 Years ago
Tue, Nov 12, 19, 00:00, 5 Years ago
Mon, Nov 11, 19, 00:00, 5 Years ago
;