質問するログイン新規登録

質問編集履歴

3

情報の補足

2020/04/17 03:43

投稿

TopingMado
TopingMado

スコア25

title CHANGED
File without changes
body CHANGED
@@ -93,4 +93,31 @@
93
93
  }
94
94
  }
95
95
 
96
+ ```
97
+ ```GAS
98
+ //開始日や終了日のデータ形式につきまして、下記の関数の実行LOGを追記します
99
+ function myFunction() {
100
+ const FortestSheet = SpreadsheetApp.getActive().getSheetByName("fortest");
101
+ const EventInfoSheet = SpreadsheetApp.getActive().getSheetByName("EventInfo");
102
+ const EventInfoValues = EventInfoSheet.getDataRange().getValues();
103
+ var LastCol = FortestSheet.getLastColumn()-2;
104
+ var ValueList=[];
105
+
106
+ for(var i=0;i<EventInfoValues.length;i++){
107
+ if(EventInfoValues[i][0]!="" && EventInfoValues[i][0]!=""){
108
+ var TestList = [];
109
+ TestList.push(EventInfoValues[i][0]);
110
+ TestList.push(EventInfoValues[i][1]);
111
+ TestList.push(EventInfoValues[i][2]);
112
+ TestList.push(EventInfoValues[i][3]);
113
+ ValueList.push(TestList);
114
+ }
115
+ }
116
+ Logger.log(ValueList);
117
+ }
118
+
119
+ /*Log ※if(EventInfoValues[i][0]!="" && EventInfoValues[i][0]!="")にすると、タイトル行が出力されてしまいます
120
+ [20-04-17 12:31:01:089 JST] [[イベント名, タイプ, 開始日, 完了日], [イベントA, イベントミッション, Sat Apr 04 00:00:00 GMT+09:00 2020, Fri Apr 24 00:00:00 GMT+09:00 2020], [イベントB, イベントステージ, Sun Apr 05 00:00:00 GMT+09:00 2020, Wed Apr 15 00:00:00 GMT+09:00 2020], [イベントC, イベントミッション, Mon Apr 06 00:00:00 GMT+09:00 2020, Wed Apr 08 00:00:00 GMT+09:00 2020], [イベントD, イベントステージ, Tue Apr 07 00:00:00 GMT+09:00 2020, Sat Apr 11 00:00:00 GMT+09:00 2020], [イベントE, イベントミッション, Fri Apr 10 00:00:00 GMT+09:00 2020, Tue Apr 14 00:00:00 GMT+09:00 2020]]
121
+ */
122
+
96
123
  ```

2

説明の補足

2020/04/17 03:43

投稿

TopingMado
TopingMado

スコア25

title CHANGED
File without changes
body CHANGED
@@ -48,4 +48,49 @@
48
48
  }
49
49
  }
50
50
 
51
+ ```
52
+ FortestSheetに日付を一括出力する関数
53
+ ```GAS
54
+ const SetCalenderByRealseDate=()=> {
55
+ const TestSheet = SpreadsheetApp.getActive().getSheetByName("fortest");
56
+ const realseDate = SpreadsheetApp.getActive().getSheetByName("Date").getRange("A2").getValue();
57
+ var LastCol = TestSheet.getLastColumn()-2;
58
+ var month=[];
59
+ var SetDay=[];
60
+ var SetDate=[];
61
+ CountEndDate(realseDate,SetDay,SetDate,month,LastCol);
62
+
63
+ for(var y = 0;y<SetDay.length;y++){
64
+ TestSheet.getRange(1,3+y).setValue(month[y]);
65
+ TestSheet.getRange(2,3+y).setValue(SetDate[y]);
66
+ TestSheet.getRange(3,3+y).setValue(SetDay[y]);
67
+ }
68
+ }
69
+
70
+ const CountEndDate=(realseDate,SetDay,SetDate,month,LastCol)=>{
71
+ const YobiList= ["日", "月", "火", "水", "木", "金", "土"];
72
+ var StartDate = new Date(realseDate.setDate(realseDate.getDate()-1));
73
+ for(var i=0;i<LastCol;i++){
74
+ var CountDate = new Date(StartDate.setDate(StartDate.getDate()+1));
75
+ var Yobi = CountDate.getDay();
76
+ var monthDate = Utilities.formatDate(CountDate, 'Asia/Tokyo', 'MM');
77
+ //CheckDateは月の初めであるかを判定するため
78
+ var CheckDate = Utilities.formatDate(CountDate, 'Asia/Tokyo', 'd');
79
+ var CountDate = Utilities.formatDate(CountDate, 'Asia/Tokyo', 'MM/dd');
80
+ var CountYobi = YobiList[Yobi];
81
+ //一回目は月を配列に格納、それ以降は1日のみ月を格納し、他は空欄で出力
82
+ if(i==0){
83
+ month.push(monthDate);
84
+ }
85
+ else if(i!=0 && CheckDate==1){
86
+ month.push(monthDate);
87
+ }
88
+ else {
89
+ month.push("");
90
+ }
91
+ SetDate.push(CountDate);
92
+ SetDay.push(CountYobi);
93
+ }
94
+ }
95
+
51
96
  ```

1

説明の補足

2020/04/15 02:20

投稿

TopingMado
TopingMado

スコア25

title CHANGED
File without changes
body CHANGED
@@ -1,7 +1,11 @@
1
1
  ### 前提・実現したいこと
2
2
  EventInfoSheetの内容に応じて、カレンダー(FortestSheet)にイベント名、イベントタイプ、イベント期間のセールを特定の色に変更したいですが、実行しても何も起きなかったです。
3
3
 
4
+ 【EventInfoSheet】
5
+ イベント詳細を格納するシート
4
6
  ![EventInfoSheet](777ecdc05d39a669a6ef5d1ffc5eda7c.png)
7
+ 【FortestSheet】
8
+ 別の関数で3列目から1行目に月、2行目に日付(表示形式はdd)、3行目に曜日を出力させています。
5
9
  ![FortestSheet](fb8905b7f736f34576e627bed907d950.png)
6
10
  ### 該当のソースコード
7
11