【发布时间】:2021-12-21 10:30:21
【问题描述】:
我想不使用 importrange 将数据从一张 G-sheet 移动到另一张 G-sheet。 如何在 Appscript 中做到这一点?
【问题讨论】:
标签: google-sheets
我想不使用 importrange 将数据从一张 G-sheet 移动到另一张 G-sheet。 如何在 Appscript 中做到这一点?
【问题讨论】:
标签: google-sheets
使用
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)
然后删除原来的
【讨论】:
从要从中提取数据的主工作表中,使用以下内容:-
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
【讨论】: