谷歌应用程序脚本:内置电子表格函数脚本失败 - 语法错误? [英] google apps script: built-in spreadsheet functions fail in script - wrong syntax?

查看:210
本文介绍了谷歌应用程序脚本:内置电子表格函数脚本失败 - 语法错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习GAS并希望在我的脚本中使用电子表格功能。作为一个测试,我做了一个简单的案例,但保存它扔参考错误:'左'没有定义。

I am learning GAS and want to use spreadsheet functions within my script. As a test I did a simple case but on save it threw "reference Error: 'Left' is not defined." I've looked through examples of code and can't see an alternate syntax.

function testLeft(){
  return LEFT("abcdef",3); 
}

第二个简单测试,结果相同

A second simple test, same result

function testNow(){
return Now()
}

有什么建议吗?我疯狂的猜测是脚本中有一个特殊的语法来使用内置的电子表格函数。或者,也许并非所有直接在电子表格中可用的功能都可用于GAS?

Any suggestions? My wild guess is that there is a special syntax within scripts for using a built-in spreadsheet function. Or maybe not all functions available directly in spreadsheets are available for use in GAS?

谢谢。

推荐答案

这是我在模拟mid函数的尝试

This is my attempt at simulating the mid Function

function fMid(varInStr, intPlace) {
//GAS does not have a Mid Function so I have made this one for now
//varInStr is the input string and you want a character returned from it at a given position
//intPlace is the position of the character you want
//Example
//=fMid("123456789", 9) returns "9"

var P
var N

P = intPlace -1
N = intPlace

return varInStr.substring(P,N)
};

这篇关于谷歌应用程序脚本:内置电子表格函数脚本失败 - 语法错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆