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

スプレッドシートの空白セルを直前の値で埋めたい

A列の空白セルに直前の値を入れたくて書いたコードです スプレッドシートに以下のようなBeforeの表があるとき (A列に空白セルがある) Before 1 A B 2 エリア 都市 3 東京 新宿 4 渋谷 5 池袋 6 神奈川 横浜 7 川崎 8 相模原 9 千葉 千葉 10 ...