Google Apps脚本,使用格式将一个电子表格复制到另一个电子表格 [英] Google Apps Script, copy one spreadsheet to another spreadsheet with formatting
问题描述
我想使用Google Apps脚本将Google电子表格中的单个工作表复制到另一个Google电子表格中,并且我希望保留格式(包括合并的单元格)。有没有办法做到这一点?我已经尝试了以下功能:
copyTo()
copyFormatToRange()
只能在同一电子表格内工作,并且不允许在不同电子表格之间复制数据。有没有人有什么建议?谢谢!
你看过这里:
$ b https://developers.google.com/apps-script/reference/spreadsheet/sheet#copyTo( Spreadsheet)
copyTo(电子表格)
将工作表复制到另一个电子表格。目标电子表格可以是源代码。新电子表格的名称将为原始电子表格名称的副本。
var source = SpreadsheetApp.getActiveSpreadsheet();
var sheet = source.getSheets()[0];
var destination = SpreadsheetApp.openById(ID_GOES HERE);
sheet.copyTo(destination);
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!
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);
这篇关于Google Apps脚本,使用格式将一个电子表格复制到另一个电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!