0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Googleカレンダーの予定をスプレッドシートに出力してテキスト化する方法

Posted at

Googleカレンダーの予定をスプレッドシートに出力してテキスト化する方法

Googleカレンダーの予定をまとめてスプレッドシートに出力すると、テキスト化や共有が簡単になります。

1. 前準備

  1. Googleスプレッドシートを開いて新規作成

    • 名前は任意(例: カレンダー出力
  2. 上のメニューから 拡張機能 → Apps Script を選択

    • 新しいタブでスクリプトエディタが開きます

2. カレンダーIDの確認

  1. Googleカレンダーを開く

  2. 左サイドバーの「マイカレンダー」から対象カレンダーを選択

  3. 「カレンダー設定」 → 「カレンダーの統合」 → 「カレンダーID」を確認

    • メインカレンダーなら GmailアドレスがIDになります

3. スクリプトを書く

function exportCalendarToSheet() {
  var calendarId = 'あなたのカレンダーID'; // カレンダーIDを入力
  var calendar = CalendarApp.getCalendarById(calendarId);

  var startDate = new Date('2025-01-01');
  var endDate = new Date('2025-12-31');

  var events = calendar.getEvents(startDate, endDate);
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

  sheet.clearContents();
  sheet.appendRow(['タイトル','開始','終了','場所','説明']);

  events.forEach(function(event){
    sheet.appendRow([
      event.getTitle(),
      Utilities.formatDate(event.getStartTime(), Session.getScriptTimeZone(), 'yyyy-MM-dd HH:mm:ss'),
      Utilities.formatDate(event.getEndTime(), Session.getScriptTimeZone(), 'yyyy-MM-dd HH:mm:ss'),
      event.getLocation(),
      event.getDescription()
    ]);
  });
}

ポイント

  • Utilities.formatDate で日時のフォーマットを自由に設定可能
  • Session.getScriptTimeZone() でスクリプトのタイムゾーンに合わせて出力

4. 実行

  1. 上のメニューで ▶ 実行 をクリック

  2. 初回は権限の承認が必要

    • 「Google カレンダーにアクセス」などの承認を進める
  3. 実行完了すると、スプレッドシートに予定が一覧で出力される

5. テキスト化・共有

  • スプレッドシートに出力されたデータをコピーすれば、そのままメールやチャットで共有可能
  • CSV形式でダウンロードして他ツールで加工することも可能
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?