【发布时间】:2020-03-11 14:24:31
【问题描述】:
我有创建标签的代码和复制格式的代码,但是,我正在寻找这两者的集成。我想在给定特定列表的情况下创建选项卡,然后将选项卡的格式(称为模板)粘贴到新创建的选项卡中。
这是创建标签的代码:
function createTabs() {
var ss = SpreadsheetApp.getActive()
ss.getSheetByName('Campaigns').getRange('A2:A40').getValues().filter(String)
.forEach(function (sn) {
if (!ss.getSheetByName(sn[0])) {
ss.insertSheet(sn[0], ss.getSheets().length);}})}
这是我找到的粘贴格式代码:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var source = ss.getSheets()[0];
var range = source.getRange("B2:D4");
// This copies the formatting in B2:D4 in the source sheet to
// D4:F6 in the sheet with gridId 1555299895. Note that you can get the gridId
// of a sheet by calling sheet.getSheetId() or range.getGridId().
range.copyFormatToRange(1555299895, 4, 6, 4, 6);
【问题讨论】:
标签: google-apps-script google-sheets format google-sheets-api