I have been playing around with Google Apps Script today and I am trying to code some custom spreadsheet functions. I have done some searching but cannot find an answer to my query.
I know that on a Google Spreadsheet you can use ImportRange in a cell on a spreadsheet like this:
=ImportRange(spreadsheet_key;sheet!range_of_cells)
My questions are is it possible to do something similar in a Google Apps Script and if so, how?
I want to import a range of cells from a sheet on another spreadsheet (not a sheet on the spreadsheet where the script will reside).
Yes, this is perfectly possible. You just need to call
SpreadsheetApp.openByIdand then get the desired sheet and ranges normally.Please take a look at the documentation :
range.getValues()andrange.setValues()are very basic GAS methods and are pretty well described.Read the tutorial as well.