LoginSignup
0
0

More than 3 years have passed since last update.

gas + google spreadsheet メモ

Posted at

https://tonari-it.com/gas-dialog-basic/
上記を元にgoogle spreadsheetでダイアログを出して、ボタンを押すと実行されるような仕組みを実装。

gas
function showDialog() {
  const html = HtmlService.createHtmlOutputFromFile('dialog');
  SpreadsheetApp.getUi().showModalDialog(html, 'tweet取得');
}

function getTweet(){
  Logger.log("tweet取得しました");
}
html(dialog用)
<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
   <p>過去7日間のtweetを取得します。</p>
   <p style="color: red;">シート上のデータは上書きされますので必要に応じて別の場所に保存してください。</p>
    <button onclick="getTweet();">tweet取得</button>

    <script>
      function getTweet() {
        google.script.run.withSuccessHandler(() => {
           google.script.host.close();
           alert('tweet取得に成功しました');
        }).withFailureHandler(() => {
           alert('tweet取得に失敗しました');
        }).getTweet();
      }
    </script>
  </body>
</html>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0