【问题标题】:How can I copy data from one google sheet to another? (in Appscript)如何将数据从一个谷歌表复制到另一个? (在 Appscript 中)
【发布时间】:2021-12-21 10:30:21
【问题描述】:

我想不使用 importrange 将数据从一张 G-sheet 移动到另一张 G-sheet。 如何在 Appscript 中做到这一点?

【问题讨论】:

    标签: google-sheets


    【解决方案1】:

    使用

    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)
    

    然后删除原来的

    【讨论】:

      【解决方案2】:

      从要从中提取数据的主工作表中,使用以下内容:-

      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

      【讨论】:

        猜你喜欢
        • 2020-01-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-05-02
        相关资源
        最近更新 更多