LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Thursday, January 17, 2019

Googleドキュメントを作成してテキストを渡す


新規ドキュメントを作成してテキストを入れてみます





コード.gs
function createNewDoc() {
  var doc = DocumentApp.create('Document Name');
  var body = doc.getBody();
  body.setText("テキスト1\nテキスト2");
  var url = doc.getUrl();
  Logger.log(url);
}
意訳
この機能がやること
新規ドキュメントを作成する
bodyを取得する
テキストを入力する
urlを取得する
ログに出す



補足

渡すテキストが多いとこのようなエラーがでます



関連記事


参考

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

Latest post

Extracting data from Google Sheets with regular expressions

Introduction Regular expressions are a powerful tool that can be used to extract data from text.  In Google Sheets, regular expressions ca...