【问题标题】:get google doc as HTML in google app script [duplicate]在谷歌应用脚​​本中将谷歌文档作为 HTML [重复]
【发布时间】:2015-04-28 11:32:04
【问题描述】:

如何在 google app 脚本中获取 google doc 作为 HTML? 例如。我可以像这样得到文档正文。

DocumentApp.getActiveDocument().getBody();

但是当我记录它时,什么都没有。

【问题讨论】:

  • 尝试按 id 打开文档:DocumentApp.openById("");

标签: html google-apps-script google-docs


【解决方案1】:
function doc_to_html()
{
 var id = document_Id;
 var url = "https://docs.google.com/feeds/download/documents/export/Export?id="+id+"&exportFormat=html";
 var param = 
        {
          method      : "get",
          headers     : {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
          muteHttpExceptions:true,
        };
 var html = UrlFetchApp.fetch(url,param).getContentText();
}

【讨论】:

  • 谢谢,正在寻找这样的开始,但根据不同问题的不同答案认为不可能。效果很好!
  • 如果您在尝试使用此脚本时遇到 401 未经授权的错误,您可以致电 DriveApp.getRootFolder() 获取它ask for the correct permissions。实际上这个 sn-p 与the one from the other question 非常相似,并且那个有一个非常相似的行来确保 401 不会发生。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-04-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多