Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to use Google Spreadsheet functions in Google App Script?

I just discovered Google App Scripts, and I'm stumped on something already...

I am trying to write a script for a Google Spreadsheet which finds certain historical stock prices. I found that the FinanceApp service within Google App Scripts has been deprecated, and seemingly replaced by the GOOGLEFINANCE() function within Google Spreadsheets. However, it returns an array, when I need only a single cell, and the array is mucking up the works.

So I'd like to write a short script that calls the GOOGLEFINANCE() spreadsheet function, and finds just the 1 piece of info I need from the array which is returned by GOOGLEFINANCE(). However, I cannot find a way to access Spreadsheet Functions (SUM, VLOOKUP, GOOGLEFINANCE, etc) within a script.

Is there a way to access these functions in a script? Or perhaps, is there a new service which replaces the deprecated FinanceApp service?

Many thanks for any assistance!

like image 270
marko Avatar asked Oct 10 '14 05:10

marko


People also ask

Can I use Google Sheets as a API?

The Google Sheets API lets you read, write, and format Google Sheets data with your preferred programming language, including Java, JavaScript, and Python.

How do I add data to a Google spreadsheet using an app script?

The code uses the appendRow() method of the Sheet object to write a single row of data to the spreadsheet. To append a row, pass an array of values (corresponding to the columns) to the appendRow() method. For example, the code below appends a row containing two values: First name and Last name.


1 Answers

You can try this:

var trick = SpreadsheetApp.getActiveSheet().getRange('D2').setValue('=GOOGLEFINANCE("GOOG")').getValue();
like image 92
GuestGuy Avatar answered Oct 05 '22 22:10

GuestGuy