jidl jidl - 10 months ago 67
Javascript Question

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.

Answer Source

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