3 google-docs google-sheets data-extraction google-apps-script google-drive-api
是否有一种方法可以从 Google 文档导出评论,以便评论显示在 Google 表格文档的一列中,而 Google 文档中突出显示的文本显示在旁边的列中?
据我了解,可以通过 API 访问文件注释:
https://developers.google.com/drive/v3/reference/comments#methods
但是我们可以用它来提取文档的注释和突出显示的文本吗?任何帮助,将不胜感激。
Drive API首先在服务下添加。
然后试试这个:
function listComments() {
// Change docId into your document's ID
// See below on how to
var docId = '1fzYPRldd16KjsZ6OEtzgBIeGO8q5tDbxaAcqvzrJ8Us';
var comments = Drive.Comments.list(docId);
var hList = [], cList = [];
// Get list of comments
if (comments.items && comments.items.length > 0) {
for (var i = 0; i < comments.items.length; i++) {
var comment = comments.items[i];
// add comment and highlight to array's first element
hList.unshift([comment.context.value]);
cList.unshift([comment.content]);
}
// Set values to A and B
var sheet = SpreadsheetApp.getActiveSheet();
sheet.getRange("A1:A" + hList.length).setValues(hList);
sheet.getRange("B1:B" + cList.length).setValues(cList);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11525 次 |
| 最近记录: |