我想將資料從一個 G-sheet 移動到另一個不使用 importrange。我怎樣才能在 Appscript 中做到這一點?
uj5u.com熱心網友回復:
利用
var ssheet = SpreadsheetApp.openById(SPREADSHEET_ID)
var sheet = ssheet.getSheetByName(SHEET_NAME)
var values = sheet.getRange(RANGE_NOTATION).getValues()
并在您的主表中
var ssheet = SpreadsheetApp.getActiveSpreadsheet()
var sheet = ssheet.getSheetByName(SHEET_NAME)
sheet.getRange(RANGE_NOTATION).setValues(values)
然后洗掉原來的
uj5u.com熱心網友回復:
從要從中提取資料的主表中,使用以下內容:-
var ss = SpreadsheetApp.openById(ID_of_sheet) var ssname = ss.getSheetByName(Name_Of_that_particular_Sheet_in_theSpreadSheet) var DataCopied = ssname.getRange('A1:B').getValues() // "A1:B is an example StringNotation of that range from where you want to copy the data"
現在您已經從該作業表中提取了資料,使用它來將其粘貼到另一張作業表上
var ss = SpreadsheetApp.openById(ID_of_Secondsheet) var ssname = ss.getSheetByName(Name_Of_that_particular_Sheet_in_theSpreadSheet) // where you want paste the data ssname.getRange('A1:B').setValues(DataCopied) // setValues will paste the data you copied.
確保使用與從主作業表復制資料時使用的相同 rangeNotation。有關更多資訊,您可以參考檔案:- ServiceDoc
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/389891.html
標籤:谷歌表格
