问题
Can I create a Google apps script that gets information from a whole Colomn in a apps spreadsheet and do upon it an action?
I've searched the Class spreadsheet link https://developers.google.com/apps-script/class_spreadsheet but i don't know which method I am going to use actually, anyone can help giving me a push? I am new to the Google apps scripts
回答1:
Always use the .getRange()
method to select what cells you want. Then to get all the values, you call .getValues()
. Example:
var vals = sheet.getRange("C2:C").getValues();
Now vals
is a 2 dimensional array that is accessible by vals[rowNum][colNum]
. If you're grabbing only one column, the colNum
will always be 0
.
来源:https://stackoverflow.com/questions/14937550/google-apps-script-function-that-gets-a-certain-colomn-in-spreadsheet