将其包括在下面的代码中
它在同一个工作簿中工作:
// 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")
我试过了。Thant在注释中复制文本,但不作为注释。
还尝试将其作为一个围绕importrange的查询进行处理。同样的结果。
这是我试着复制的测试评论
sheet.getRange("P6").moveTo(targetSheet.getRange("P6"));
};
因为我还没有找到一种方法来把它的注释原封不动地复制成注释(注释文本可以复制,但我需要将它作为注释)复制到Archive位置。
发布于 2019-08-28 11:07:11
问题
getComments()
方法。这个功能有一个特征请求,但是目前还没有实现。解决办法
var targetSheet=SpreadsheetApp.openById('SPREADSHEETID');
SpreadsheetApp.getActive().getSheetByName("Source_Sheet").copyTo(targetSheet);
但是,这将不会复制评论。
SpreadsheetApp.getActive().copy('This is a copy');
或DriveApp.getFileById(SpreadsheetApp.getActive().getId()).makeCopy();
)也是如此。var comments=Drive.Comments.list(SpreadsheetApp.getActive().getId());
Drive.Comments.insert({"content":comments.items[0].content, "context":comments.items[0].context, "author":comments.items[0].author}, targetSheet.getId());
https://stackoverflow.com/questions/57683221
复制相似问题