Google应用程序脚本:如何在不同的函数调用之间保存电子表格中的数据? [英] Google apps script: how to persist data in spreadsheet between different function calls?

查看:109
本文介绍了Google应用程序脚本:如何在不同的函数调用之间保存电子表格中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用脚本编辑器的Google电子表格中,我会调用函数,但是我不太确定存储持久数据(我将继续使用的数据)的最佳方式是使用全局变量(使用对象,数组,字符串),或者有更好的方法来存储数据。



我不想使用可能是另一种方式的单元格。 b

另一个问题是,在这个环境中可以创建(伪)类吗?最好的方法是什么?

解决方案

可以使用Class ScriptProperties存储持久数据:



http://code.google.com/googleapps/appsscript/class_scriptproperties.html

所有值都以字符串形式存储,并且在检索时必须使用likes或parsInt或parseFloat进行转换。



JSON对象也可以以这种方式存储。


In a Google spreadsheet using the Script Editor, I do function calls, but I am not quite sure if the best way to store persistant data (data that I will continue to use) is to use global variables (using objects, arrays, strings), or there is a better way to store data.

I don't want to use cells which could be another way.

Another question, is it possible to create (pseudo) classes in this environment? Best way?

解决方案

Persistent data can be stored using the Class ScriptProperties:

http://code.google.com/googleapps/appsscript/class_scriptproperties.html

All values are stored as a string and will have to be converted back with the likes or parsInt or parseFloat when they are retrieved.

JSON objects can also be stored in this manner.

这篇关于Google应用程序脚本:如何在不同的函数调用之间保存电子表格中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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