Google Apps Script, copy one spreadsheet to another spreadsheet with formatting

前端 未结 3 1243
轻奢々
轻奢々 2020-12-05 15:23

Hopefully this question has not already been answered. I have spent a considerable amount of time searching, and although I have found similar posts, none have done exactly

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 16:00

    Have you looked here:

    https://developers.google.com/apps-script/reference/spreadsheet/sheet#copyTo(Spreadsheet)

    copyTo(spreadsheet)

    Copies the sheet to another spreadsheet. The destination spreadsheet can be the source. The new spreadsheet will have the name "Copy of [original spreadsheet name]".

     var source = SpreadsheetApp.getActiveSpreadsheet();
    
     var sheet = source.getSheets()[0];
    
     var destination = SpreadsheetApp.openById("ID_GOES HERE");
    
     sheet.copyTo(destination);
    

提交回复
热议问题