最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - what string literal is available in google apps script? - Stack Overflow

programmeradmin0浏览0评论

Looking for something in google apps script that does something similar to ES6 javascript.

Ss.main.getRange('C2').setValue('${Ss.main.getRange(2,2).getDisplayValue()}')

expected C2 cell to equal the value in B2. instead i get ${Ss.main.getRange(2,2).getDisplayValue()}

Looking for something in google apps script that does something similar to ES6 javascript.

Ss.main.getRange('C2').setValue('${Ss.main.getRange(2,2).getDisplayValue()}')

expected C2 cell to equal the value in B2. instead i get ${Ss.main.getRange(2,2).getDisplayValue()}

Share Improve this question edited Apr 12, 2019 at 0:53 zmag 8,26112 gold badges37 silver badges46 bronze badges asked Apr 12, 2019 at 0:47 MavDarknessMavDarkness 511 silver badge2 bronze badges 1
  • Although I'm not sure whether I could correctly understand about your question, do you want to copy the value of "B2" to "C2" using Google Apps Script? – Tanaike Commented Apr 12, 2019 at 0:53
Add a ment  | 

2 Answers 2

Reset to default 5

Look at there: V8 Runtime Overview

Example:

// V8 runtime
var name = `Hi ${first} ${last}.`;
var url = `http://localhost:3000/api/messages/${id}`;

The current version of Apps Script does not support ES6 string literals (but that will change with the uping V8 upgrade, hopefully in the near future). In the meantime, you can leverage the Utilities.formatString() function.

Your sample code can be converted as follows:

Ss.main.getRange('C2').setValue(Utilities.formatString(
    "%s",
    Ss.main.getRange(2,2).getDisplayValue()
));

However, if all you need to do is convert the returned value to a string then you can use the getDisplayValue() call directly (since the function returns a string by default):

Ss.main.getRange('C2').setValue(Ss.main.getRange(2,2).getDisplayValue());
发布评论

评论列表(0)

  1. 暂无评论