Apps Scriptリファレンス: Apps Script Reference |障害・課題追跡: IssueTracker |Google Workspace: Status Dashboard - Summary

2019年1月19日土曜日

Googleドキュメントにテキストを追加したい


ドキュメントに hello を入力しておいて



hi と hey を追加する




コード.gs
function addText() {
  var url = "https://docs.google.com/document/d/ID/edit";
  var doc = DocumentApp.openByUrl(url);
  var body = doc.getBody();
  body.appendParagraph("hi" + "\n" + "hey");
}


getBody()しなくても動いた。
DocumentApp.openByUrl(url).appendParagraph("hi" + "\n" + "hey")


参考

appendParagraph(text)
https://developers.google.com/apps-script/reference/document/body#appendParagraph(String)

Latest post

Google Classroom API でクラスの一覧を取得したい

自分が指導・参加しているクラスの名称とIDを取得するコードを試しました 下記 Code.gs では pageSize で 100 を設定していますが 必ず 100件 返ってくるとは限らないらしいです https://developers.google.com/workspace/...