无法访问Footnotes类Google脚本 [英] Trouble accessing Footnotes class Google Scripts

查看:114
本文介绍了无法访问Footnotes类Google脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个简单的脚本,将脚注添加到Google文档中并将其复制到尾注部分。因此,用户将按照正常方式使用脚注,然后在脚本完成时运行脚本将它们移动到文档的末尾。

I'm trying to write up a simple script which will take a footnote added to a Google Document and copy it into an endnotes section. So, the user would use footnotes as normal and then run the script to shift them to the end of the document when they're finished.

我有一个脚本它从我的测试文档返回一个包含 [脚注,脚注] 的数组,其中包含两个,但我无法弄清楚如何将该对象转换为字符串。

I've got a script which returns an array containing [Footnote, Footnote] from my test doc with two included, but I cannot figure out how to convert the object to a string.

function getNotes() {
  var doc = DocumentApp.getActiveDocument().getFootnotes();
  Logger.log(doc);
}

我对这些文档感兴趣,而且我很困惑,因为我似乎无法找到 Footnotes 类中提到的 getFootnoteContents 方法。任何方向都将得到真正的赞赏。

I've pored over the documentation, and I'm really confused because I can't seem to find the getFootnoteContents method mentioned in the Footnotes class. Any direction would be really appreciated.

推荐答案

getFootnotes()返回一个脚注对象数组。您需要遍历它们才能访问每一个。

getFootnotes() return an array of footnote objects. You will need to iterate over them to access each one.

function getFootnotes(){
  var doc = DocumentApp.openById('...');
  var footnotes = doc.getFootnotes();
  for(var i in footnotes ){
    Logger.log(footnotes[i].getFootnoteContents().getText());    
  }    
}

这篇关于无法访问Footnotes类Google脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆