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 what I am trying to do.
I would like to use Google Apps Script to copy a single sheet from a Google spreadsheet into a different Google spreadsheet, and I want to retain formatting (including merged cells). Is there any way to do this? I have tried the following functions:
copyTo() copyFormatToRange()
but these methods only work within the same spreadsheet and do not allow data to be copied between different spreadsheets. Does anyone have any suggestions? Thanks!
If you want to duplicate a sheet of a particular spreadsheet, you can use:
SpreadsheetApp.getActiveSpreadsheet().duplicateActiveSheet();
This will create a copy of your current sheet and make that copy as active.
duplicateActiveSheet()
Keep scripting :)
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]".