简体   繁体   English

Google表格中的JavaScript函数

[英]JavaScript Functions In Google Sheets

Can you add JavaScript functions to .gs files and then run functions on Google Sheets? 您可以将JavaScript函数添加到.gs文件,然后在Google表格上运行函数吗?

The use case for me is to make use of Google's https://github.com/googlei18n/libphonenumber to sweep through and sanitise some phone numbers. 对我来说,用例是利用Google的https://github.com/googlei18n/libphonenumber扫过并清理一些电话号码。

This should be possible but would require some manual work of creating files in the Script Editor and manually copying and pasting the code over. 这应该可行,但是需要一些手动工作,即在“脚本编辑器”中创建文件,然后手动复制和粘贴代码。

I have had success doing this with other Javascript libraries in the past. 过去,我在使用其他Javascript库方面取得了成功。

You will need basic Javascript skills, since you'll still need to write a bit of code to leverage the library once you have it moved over. 您将需要基本的Javascript技能,因为一旦移交给该库,您仍然需要编写一些代码来利用该库。 You could use a custom formula function or you could have a function that pulls in the relevant cells from the sheet and processes them before writing them out somewhere. 您可以使用自定义公式函数,也可以使用一个函数,该函数可以从工作表中提取相关单元格并对其进行处理,然后再将其写出。

For custom spreadsheet formulas, see: https://developers.google.com/apps-script/guides/sheets/functions 有关自定义电子表格公式的信息,请参见: https : //developers.google.com/apps-script/guides/sheets/functions

For processing sheet data within the script, see: https://developers.google.com/apps-script/guides/sheets 有关在脚本中处理工作表数据的信息,请参见: https : //developers.google.com/apps-script/guides/sheets

Google Apps Script is based on JavaScript, so yes, it's possible. Google Apps脚本基于JavaScript,因此可以。 See Using open-source libraries in Apps Script . 请参阅在Apps脚本中使用开源库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM