質問編集履歴

3

情報の補足

2020/04/17 03:43

投稿

TopingMado
TopingMado

スコア25

test CHANGED
File without changes
test CHANGED
@@ -189,3 +189,57 @@
189
189
 
190
190
 
191
191
  ```
192
+
193
+ ```GAS
194
+
195
+ //開始日や終了日のデータ形式につきまして、下記の関数の実行LOGを追記します
196
+
197
+ function myFunction() {
198
+
199
+ const FortestSheet = SpreadsheetApp.getActive().getSheetByName("fortest");
200
+
201
+ const EventInfoSheet = SpreadsheetApp.getActive().getSheetByName("EventInfo");
202
+
203
+ const EventInfoValues = EventInfoSheet.getDataRange().getValues();
204
+
205
+ var LastCol = FortestSheet.getLastColumn()-2;
206
+
207
+ var ValueList=[];
208
+
209
+
210
+
211
+ for(var i=0;i<EventInfoValues.length;i++){
212
+
213
+ if(EventInfoValues[i][0]!="" && EventInfoValues[i][0]!=""){
214
+
215
+ var TestList = [];
216
+
217
+ TestList.push(EventInfoValues[i][0]);
218
+
219
+ TestList.push(EventInfoValues[i][1]);
220
+
221
+ TestList.push(EventInfoValues[i][2]);
222
+
223
+ TestList.push(EventInfoValues[i][3]);
224
+
225
+ ValueList.push(TestList);
226
+
227
+ }
228
+
229
+ }
230
+
231
+ Logger.log(ValueList);
232
+
233
+ }
234
+
235
+
236
+
237
+ /*Log ※if(EventInfoValues[i][0]!="" && EventInfoValues[i][0]!="")にすると、タイトル行が出力されてしまいます
238
+
239
+ [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]]
240
+
241
+ */
242
+
243
+
244
+
245
+ ```

2

説明の補足

2020/04/17 03:43

投稿

TopingMado
TopingMado

スコア25

test CHANGED
File without changes
test CHANGED
@@ -99,3 +99,93 @@
99
99
 
100
100
 
101
101
  ```
102
+
103
+ FortestSheetに日付を一括出力する関数
104
+
105
+ ```GAS
106
+
107
+ const SetCalenderByRealseDate=()=> {
108
+
109
+ const TestSheet = SpreadsheetApp.getActive().getSheetByName("fortest");
110
+
111
+ const realseDate = SpreadsheetApp.getActive().getSheetByName("Date").getRange("A2").getValue();
112
+
113
+ var LastCol = TestSheet.getLastColumn()-2;
114
+
115
+ var month=[];
116
+
117
+ var SetDay=[];
118
+
119
+ var SetDate=[];
120
+
121
+ CountEndDate(realseDate,SetDay,SetDate,month,LastCol);
122
+
123
+
124
+
125
+ for(var y = 0;y<SetDay.length;y++){
126
+
127
+ TestSheet.getRange(1,3+y).setValue(month[y]);
128
+
129
+ TestSheet.getRange(2,3+y).setValue(SetDate[y]);
130
+
131
+ TestSheet.getRange(3,3+y).setValue(SetDay[y]);
132
+
133
+ }
134
+
135
+ }
136
+
137
+
138
+
139
+ const CountEndDate=(realseDate,SetDay,SetDate,month,LastCol)=>{
140
+
141
+ const YobiList= ["日", "月", "火", "水", "木", "金", "土"];
142
+
143
+ var StartDate = new Date(realseDate.setDate(realseDate.getDate()-1));
144
+
145
+ for(var i=0;i<LastCol;i++){
146
+
147
+ var CountDate = new Date(StartDate.setDate(StartDate.getDate()+1));
148
+
149
+ var Yobi = CountDate.getDay();
150
+
151
+ var monthDate = Utilities.formatDate(CountDate, 'Asia/Tokyo', 'MM');
152
+
153
+ //CheckDateは月の初めであるかを判定するため
154
+
155
+ var CheckDate = Utilities.formatDate(CountDate, 'Asia/Tokyo', 'd');
156
+
157
+ var CountDate = Utilities.formatDate(CountDate, 'Asia/Tokyo', 'MM/dd');
158
+
159
+ var CountYobi = YobiList[Yobi];
160
+
161
+ //一回目は月を配列に格納、それ以降は1日のみ月を格納し、他は空欄で出力
162
+
163
+ if(i==0){
164
+
165
+ month.push(monthDate);
166
+
167
+ }
168
+
169
+ else if(i!=0 && CheckDate==1){
170
+
171
+ month.push(monthDate);
172
+
173
+ }
174
+
175
+ else {
176
+
177
+ month.push("");
178
+
179
+ }
180
+
181
+ SetDate.push(CountDate);
182
+
183
+ SetDay.push(CountYobi);
184
+
185
+ }
186
+
187
+ }
188
+
189
+
190
+
191
+ ```

1

説明の補足

2020/04/15 02:20

投稿

TopingMado
TopingMado

スコア25

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,15 @@
4
4
 
5
5
 
6
6
 
7
+ 【EventInfoSheet】
8
+
9
+ イベント詳細を格納するシート
10
+
7
11
  ![EventInfoSheet](777ecdc05d39a669a6ef5d1ffc5eda7c.png)
12
+
13
+ 【FortestSheet】
14
+
15
+ 別の関数で3列目から1行目に月、2行目に日付(表示形式はdd)、3行目に曜日を出力させています。
8
16
 
9
17
  ![FortestSheet](fb8905b7f736f34576e627bed907d950.png)
10
18