jidl
jidl

Reputation: 295

JavaScript Functions In Google Sheets

Can you add JavaScript functions to .gs files and then run functions on Google Sheets?

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.

Upvotes: 0

Views: 975

Answers (2)

Cameron Roberts
Cameron Roberts

Reputation: 7367

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.

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. 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

For processing sheet data within the script, see: https://developers.google.com/apps-script/guides/sheets

Upvotes: 4

Wicket
Wicket

Reputation: 38131

Google Apps Script is based on JavaScript, so yes, it's possible. See Using open-source libraries in Apps Script.

Upvotes: 1

Related Questions