【发布时间】:2020-01-01 03:20:35
【问题描述】:
- 试图将评论从一个 google 工作表复制到另一个位置的工作表副本。
- 似乎没有 copyTo(),所以我正在尝试 moveTo()
- 寻找更多想法。
在下面的代码中包含这个
它在同一个工作簿中工作:
// This works
function copyCellAndComments() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Source_Sheet");
var targetSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Destination_Sheet");
sheet.getRange("P21:26").moveTo(targetSheet.getRange("P21:26"));
};
// I run into permissions issues if I try something like
function copyCellAndComments02() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Source_Sheet");
//This didn't work. Told me formatted wrong
var targetSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Spreadsheet URL", "Sheetname");
// I tried using SpreadsheetApp.openById() as well as SpreadsheetApp.openByUrl() in the script and it told me I don't have sufficient permissions to run openById or openByUrl.
// (Error
Exception: You do not have permission to call SpreadsheetApp.openByUrl. Required permissions: https://www.googleapis.com/auth/spreadsheets )
// Also tried creating a standalone function and calling the function within the sheet.
function importComments(spreadsheetKey,a1NotationReference) {
return SpreadsheetApp.openByUrl(spreadsheetKey).getRange(a1NotationReference).getComments();
};
在网上找到了一些东西,说如果我添加一个菜单并从菜单中调用它就会运行。
// That generates an Error - Exception: Invalid argument: url (line 7, file "MyScripts_RickP")
我尝试了 importrange。 Thant 复制评论中的文本,但不作为评论。
还尝试将其作为围绕导入范围的查询来执行。结果一样。
这是我要复制的测试评论
sheet.getRange("P6").moveTo(targetSheet.getRange("P6"));
};
因为我还没有找到一种方法将带有完整 cmets 的工作表作为评论(评论文本复制好,但我需要将其作为评论复制)复制到存档位置。
【问题讨论】:
标签: google-apps-script google-sheets-formula