質問編集履歴
3
#を1つにしたら\マークが出るの?
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|
2
あっ、#の数を減らしたら、文字の大きさが大きくなるんですね!! こりゃいいや。
title
CHANGED
File without changes
|
body
CHANGED
@@ -95,4 +95,72 @@
|
|
95
95
|
|
96
96
|
### 追記
|
97
97
|
関連の質問を投稿しました。もしよかったら見てください。
|
98
|
-
[https://teratail.com/questions/116569](https://teratail.com/questions/116569)
|
98
|
+
[https://teratail.com/questions/116569](https://teratail.com/questions/116569)
|
99
|
+
|
100
|
+
|
101
|
+
#**~解決後のまとめ~**
|
102
|
+
stshishoさんの回答を参考に解決しましたので、まとめておきます。
|
103
|
+
|
104
|
+
---
|
105
|
+
完成形です。
|
106
|
+
あ、でもなにか思うところがあれば、コメントしていただけるとうれしいです。
|
107
|
+
|
108
|
+
```javaScript
|
109
|
+
function sendNotification() {
|
110
|
+
//変数spreadsheetに指定のスプレッドシートオブジェクトを取得します
|
111
|
+
var url = "***";
|
112
|
+
var sheet = SpreadsheetApp.openByUrl(url);
|
113
|
+
var ss = SpreadsheetApp.getActiveSpreadsheet();
|
114
|
+
var val = sheet.getRange('B'+ sheet.getLastRow()).getValue();
|
115
|
+
var val2 = sheet.getRange('D'+ sheet.getLastRow()).getValue();
|
116
|
+
var val3 = sheet.getRange('A'+ sheet.getLastRow()).getValue();
|
117
|
+
// もし列Dの値に異動があれば
|
118
|
+
if(val2!=''){ // = if you edit data in col D
|
119
|
+
var dAddress = "***";
|
120
|
+
var subject = "***";
|
121
|
+
var content = "名前:"+val+"\n";
|
122
|
+
content += Utilities.formatDate(val3,'JST','yyyy年M月d日 H時m分')+"\n";
|
123
|
+
content += "**********************\n"+val2;
|
124
|
+
MailApp.sendEmail(dAddress,subject,content);
|
125
|
+
}
|
126
|
+
|
127
|
+
var target_col = 1;
|
128
|
+
var asc = false;
|
129
|
+
var start_row = 2;
|
130
|
+
var start_col = 1;
|
131
|
+
|
132
|
+
var sh = SpreadsheetApp.getActiveSheet();
|
133
|
+
var last_col = sh.getLastColumn();
|
134
|
+
var last_row = sh.getLastRow();
|
135
|
+
var num_rows = last_row - (start_row - 1);
|
136
|
+
var num_cols = last_col - (start_col - 1);
|
137
|
+
var range = sh.getRange(start_row, start_col, num_rows, num_cols);
|
138
|
+
range.sort([{
|
139
|
+
column: target_col,
|
140
|
+
ascending: asc
|
141
|
+
}]);
|
142
|
+
}
|
143
|
+
```
|
144
|
+
|
145
|
+
### 参考記事(2018/03/27 追記)
|
146
|
+
・[https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q10173170780](https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q10173170780)
|
147
|
+
こちらのベストアンサーの方の書かれたスクリプトをベースにしました。
|
148
|
+
・[https://tonari-it.com/gas-moment-js-format/](https://tonari-it.com/gas-moment-js-format/)
|
149
|
+
日付と時刻の書式フォーマットに関するスクリプトをお借りしました。
|
150
|
+
・[http://www.pre-practice.net/2016/06/blog-post_22.html](http://www.pre-practice.net/2016/06/blog-post_22.html)
|
151
|
+
データのソートに関するスクリプトをお借りしました。
|
152
|
+
あと、「getLastRow()」で一番下の行を取得できることを知りました。
|
153
|
+
・[http://emplos.jp/news/3336.html](http://emplos.jp/news/3336.html)
|
154
|
+
「\n」と書くと文章が改行されることを知りました。
|
155
|
+
変数内で「+=」と書くと、文章を追加できることを知りました。これを使うと見やすくなる。
|
156
|
+
・[https://teratail.com/questions/116487](https://teratail.com/questions/116487)
|
157
|
+
当記事です。特定のセルの値を走査する方法を教えていただきました。
|
158
|
+
|
159
|
+
本題から若干それますが、
|
160
|
+
・[https://code.i-harness.com/ja/q/ea05cb](https://code.i-harness.com/ja/q/ea05cb)
|
161
|
+
ここから「function sendNotification()」という関数名をいただいたみたいです。
|
162
|
+
・[https://qiita.com/nurburg/items/744ec53477f4ae328555](https://qiita.com/nurburg/items/744ec53477f4ae328555)
|
163
|
+
URLを指定して別のスプレッドシートを開く方法はこちらの記事からいただいたみたいですが、
|
164
|
+
そんなことしなくても、「getActiveSheet()」でいいと、いまとなってはわかるのです…。
|
165
|
+
|
166
|
+
以上、おそらくこのあたりの記事を参考にしたのだと思われます。
|
1
追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -91,4 +91,8 @@
|
|
91
91
|
私が素人だからそう思うのかはわかりませんが、みなさまのお知恵をお貸しいただけると、幸いです。
|
92
92
|
|
93
93
|
当方、先にも述べましたが、ずぶの素人なので、的外れなことを書いていたらすみません。
|
94
|
-
多少、大目に見ていただけると、ありがたいです。
|
94
|
+
多少、大目に見ていただけると、ありがたいです。
|
95
|
+
|
96
|
+
### 追記
|
97
|
+
関連の質問を投稿しました。もしよかったら見てください。
|
98
|
+
[https://teratail.com/questions/116569](https://teratail.com/questions/116569)
|