0

Google sheets scripts

Example:

  1. Varxx = Math.floor(3.4) //works with JavaScript Math method

  2. Varxx = INT(3.4) // Does not work ...

ReferenceError: "INT" is not defined.

I would like access to the other functions that are available in Google sheets, so how to make approach 2. work? Or what primer/tutorial should I be reading?

Chemi Adel
  • 1,964
  • 1
  • 10
  • 18
Richard Foye
  • 1
  • 1
  • 1
  • I think you'll find this question addressed here https://stackoverflow.com/questions/25234912/how-to-use-native-spreadsheet-functions-in-google-apps-script – Tom Woodward Feb 06 '20 at 19:01
  • 1
    Does this answer your question? [Using built-in spreadsheet functions in a script](https://stackoverflow.com/questions/11660574/using-built-in-spreadsheet-functions-in-a-script) – Kos Feb 06 '20 at 21:06
  • Thanks. That answers it (the answer is 'no'). I searched but somehow didn't find these threads. The available Javascript functions will suffice. – Richard Foye Feb 07 '20 at 17:29

2 Answers2

2

Google apps script is predominantly Javascript.

I don't think google sheet formulas are available in google apps script but (almost) all the javascript functionalities are available, so we can use those.

For example :

Google Sheet INT equivalent in javascript is Math.floor

console.log(Math.floor(3.4))

As mentioned in another answer, we can use parseInt also.

console.log(parseInt(3.4))
Umair Mohammad
  • 4,489
  • 2
  • 20
  • 34
2

you can also cast with parse

varxx = parseInt(variable)
J. G.
  • 1,922
  • 1
  • 11
  • 21