質問編集履歴
5
追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -224,4 +224,17 @@
|
|
224
224
|
</div>
|
225
225
|
</body>
|
226
226
|
</html>
|
227
|
+
```
|
228
|
+
|
229
|
+
さらに、現在は、以下のエラーが出ており困っております
|
230
|
+
|
231
|
+
ReferenceError: 「url」が定義されていません。(行 27、ファイル「stuff」)
|
232
|
+
この部分で、うまくURLを取得できていないようで、困り果てております。
|
233
|
+
```js
|
234
|
+
//修正画面リンクを埋め込む関数
|
235
|
+
function getModifyUrl (no, name) {
|
236
|
+
var modifyUrl = url + "/exec?name=modify&no=" + no;
|
237
|
+
return '<a href="' + modifyUrl + '" target="_top">' + name + '</a>';
|
238
|
+
};
|
239
|
+
コード
|
227
240
|
```
|
4
説明文の追加と修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
参考URL;https://note.com/consul_addtag/n/nd581fe122540
|
3
3
|
に記載の社員管理システムをGASで作りたいのですが、
|
4
4
|
一度、成功したのですが、2回目以降、何度やっても、以下のエラーが出てきます。
|
5
|
+
|
5
6
|
スプレッドシートのID指定時は、'XxXXXXXX' シングルクオーテーションで囲み、
|
6
7
|
シート名は、ダブルクオーテーションで囲っても、シングルクオーテーションで囲ってもエラー内容は同じ物が出ます
|
7
8
|
### 発生している問題・エラーメッセージ
|
3
追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
参考URL;https://note.com/consul_addtag/n/nd581fe122540
|
3
3
|
に記載の社員管理システムをGASで作りたいのですが、
|
4
4
|
一度、成功したのですが、2回目以降、何度やっても、以下のエラーが出てきます。
|
5
|
-
|
5
|
+
スプレッドシートのID指定時は、'XxXXXXXX' シングルクオーテーションで囲み、
|
6
|
+
シート名は、ダブルクオーテーションで囲っても、シングルクオーテーションで囲ってもエラー内容は同じ物が出ます
|
6
7
|
### 発生している問題・エラーメッセージ
|
7
8
|
|
8
9
|
```
|
2
追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,10 +6,220 @@
|
|
6
6
|
### 発生している問題・エラーメッセージ
|
7
7
|
|
8
8
|
```
|
9
|
+
ine.html
|
9
10
|
TypeError: output.append is not a function(行 59)
|
10
11
|
```
|
11
12
|
|
12
13
|
### 該当のソースコード
|
13
14
|
入力制限をこえてしまうので、
|
14
15
|
参考URL;https://note.com/consul_addtag/n/nd581fe122540を参照ください。
|
15
|
-
よろしくお願いいたします。
|
16
|
+
よろしくお願いいたします。
|
17
|
+
```html
|
18
|
+
<!DOCTYPE html>
|
19
|
+
<html>
|
20
|
+
<head>
|
21
|
+
<base target="_top">
|
22
|
+
</head>
|
23
|
+
<body>
|
24
|
+
<style>
|
25
|
+
#header-fixed{
|
26
|
+
border: 5px solid #fff; /* 表示領域を白枠で囲う */
|
27
|
+
position: fixed; /* ヘッダーの固定 */
|
28
|
+
padding:10px 0 20px; /* 上10px、下20pxをあける */
|
29
|
+
top: 0px; /* 位置(上0px) */
|
30
|
+
left: 10px; /* 位置(右0px) */
|
31
|
+
width: 100%; /* 横幅100% */
|
32
|
+
height:70px; /* 縦幅70px */
|
33
|
+
background-color:#FFF /* バックの色 */
|
34
|
+
}
|
35
|
+
#content{
|
36
|
+
top: 80px; /* 位置(上0px) */
|
37
|
+
left: 0px; /* 位置(右0px) */
|
38
|
+
padding:110px 0 0px;
|
39
|
+
width: 100%; /* 横幅100% */
|
40
|
+
background-color: "#000000" /* バックの色 */
|
41
|
+
}
|
42
|
+
#menu{
|
43
|
+
font-size : 20px;
|
44
|
+
border : 1px;
|
45
|
+
padding : 10px 20px 0px 0px;
|
46
|
+
}
|
47
|
+
thead {
|
48
|
+
display: block;
|
49
|
+
}
|
50
|
+
tbody {
|
51
|
+
overflow-x: hidden;
|
52
|
+
overflow-y: scroll;
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
<?
|
56
|
+
url = "https://script.google.com/macros/s/[App-ID]";
|
57
|
+
?>
|
58
|
+
<div id='header-fixed'>
|
59
|
+
<font size="5pt" color="#5555ff">社員管理システム </font>
|
60
|
+
<a id='menu' href="<?=url?>/exec?name=view">再表示</a>
|
61
|
+
<a id='menu' href="<?=url?>/exec?name=inputStuff">社員登録</a>
|
62
|
+
<!-- <font size='5px'> 只今の時刻<span id="clock_time"></span>です。</font> -->
|
63
|
+
</div>
|
64
|
+
<!-- ↑↑↑メニュー↑↑↑-->
|
65
|
+
<script>
|
66
|
+
function clock()
|
67
|
+
{
|
68
|
+
// 現在日時を表すインスタンスを取得
|
69
|
+
// var now = new Date();
|
70
|
+
// document.getElementById("clock_time").innerHTML = now;
|
71
|
+
}
|
72
|
+
setInterval(clock, 1000);
|
73
|
+
</script>
|
74
|
+
<?
|
75
|
+
myMail = Session.getActiveUser().getEmail();
|
76
|
+
output.append('<font size="2px" color="#5555ff">ログインユーザー:');
|
77
|
+
output.append( myMail);
|
78
|
+
?>
|
79
|
+
<div id='content'>
|
80
|
+
<?
|
81
|
+
//スタッフリストのスプレッドIDを指定
|
82
|
+
var id =[シートのIDを指定];
|
83
|
+
var mySheet = SpreadsheetApp.openById(id).getSheetByName("スタッフ");
|
84
|
+
var endrow = mySheet.getLastRow();
|
85
|
+
var headData = mySheet.getRange("A1:N1").getValues();
|
86
|
+
var myData = mySheet.getRange(2, 1 , endrow-1 , 14).getValues();
|
87
|
+
output.append('<table border="1" cellspacing="0" cellpadding="5" bordercolor="#333333" style="table-layout:fixed;width:100%;">');
|
88
|
+
output.append('<thead><div fixed>');
|
89
|
+
output.append('<colgroup>');
|
90
|
+
output.append('<col style="width:3%;"><col style="width:7%;"><col><col><col><col><col><col style="width:20%;"><col style="width:10%;"><col><col style="width:10%;"><col style="width:15%;"><col style="width:5%;"><col>');
|
91
|
+
output.append('</colgroup>');
|
92
|
+
output.append('<tr>');
|
93
|
+
headprefix = '<th bgcolor="#5555ff"><font color="#FFFFFF" size="2px">';
|
94
|
+
headbackfix = '</font></th>';
|
95
|
+
|
96
|
+
//ヘッダー情報取得
|
97
|
+
no = headData[0][0];
|
98
|
+
name = headData[0][1];
|
99
|
+
commit = headData[0][2];
|
100
|
+
company = headData[0][3];
|
101
|
+
payroll = headData[0][4];
|
102
|
+
roll = headData[0][5];
|
103
|
+
post = headData[0][6];
|
104
|
+
profile = headData[0][7];
|
105
|
+
tag = headData[0][8];
|
106
|
+
avalable = headData[0][9];
|
107
|
+
address = headData[0][10];
|
108
|
+
facebook = headData[0][11];
|
109
|
+
ndadate = headData[0][12];
|
110
|
+
status = headData[0][13];
|
111
|
+
|
112
|
+
//テーブルヘッダー作成
|
113
|
+
output.append(headprefix + no + headbackfix);
|
114
|
+
output.append(headprefix + name + headbackfix);
|
115
|
+
output.append(headprefix + commit + headbackfix);
|
116
|
+
output.append(headprefix + company + headbackfix);
|
117
|
+
output.append(headprefix + payroll + headbackfix);
|
118
|
+
output.append(headprefix + roll + headbackfix);
|
119
|
+
output.append(headprefix + post + headbackfix);
|
120
|
+
output.append(headprefix + profile + headbackfix);
|
121
|
+
output.append(headprefix + tag + headbackfix);
|
122
|
+
output.append(headprefix + avalable + headbackfix);
|
123
|
+
output.append(headprefix + address + headbackfix);
|
124
|
+
output.append(headprefix + facebook + headbackfix);
|
125
|
+
output.append(headprefix + ndadate + headbackfix);
|
126
|
+
output.append(headprefix + status + headbackfix);
|
127
|
+
output.append('</tr>');
|
128
|
+
output.append('</thead></div>');
|
129
|
+
|
130
|
+
//テーブルボディの作成
|
131
|
+
output.append('<tbody>');
|
132
|
+
y=0;
|
133
|
+
for(var i=0; i<myData.length; i++){
|
134
|
+
no = myData[i][y];
|
135
|
+
name = myData[i][y+1];
|
136
|
+
commit = myData[i][y+2];
|
137
|
+
company = myData[i][y+3];
|
138
|
+
payroll = myData[i][y+4];
|
139
|
+
roll = myData[i][y+5];
|
140
|
+
post = myData[i][y+6];
|
141
|
+
profile = myData[i][y+7];
|
142
|
+
tag = myData[i][y+8];
|
143
|
+
avalable = myData[i][y+9];
|
144
|
+
address = myData[i][y+10];
|
145
|
+
facebook = myData[i][y+11];
|
146
|
+
ndadate = myData[i][y+12];
|
147
|
+
status = myData[i][y+13];
|
148
|
+
|
149
|
+
headprefix = '<td style="word-wrap:break-word;"><font color="#000000" size="1px">';
|
150
|
+
headbackfix = '</font></td>';
|
151
|
+
|
152
|
+
if (status === "解約" || status === "退職"){
|
153
|
+
output.append('<tr bgcolor = "#333333">');
|
154
|
+
}else if(status === "停止中"){
|
155
|
+
output.append('<tr bgcolor = "#AAAAAA">');
|
156
|
+
}else{
|
157
|
+
output.append('<tr bgcolor = "#FFFFFF">');
|
158
|
+
}
|
159
|
+
output.append(headprefix + no + headbackfix);
|
160
|
+
output.append(headprefix + getModifyUrl(no,name) + headbackfix);
|
161
|
+
output.append(headprefix + commit + headbackfix);
|
162
|
+
output.append(headprefix + company + headbackfix);
|
163
|
+
output.append(headprefix + payroll + headbackfix);
|
164
|
+
output.append(headprefix + roll + headbackfix);
|
165
|
+
output.append(headprefix + post + headbackfix);
|
166
|
+
output.append(headprefix + getLink(profile) + headbackfix);
|
167
|
+
output.append(headprefix + tag + headbackfix);
|
168
|
+
output.append(headprefix + avalable + headbackfix);
|
169
|
+
output.append(headprefix + getMailAddress(address) + headbackfix);
|
170
|
+
output.append(headprefix + getLink(facebook) + headbackfix);
|
171
|
+
output.append(headprefix + getViewDate(ndadate) + headbackfix);
|
172
|
+
output.append(headprefix + status + headbackfix);
|
173
|
+
output.append('</tr>');
|
174
|
+
}
|
175
|
+
output.append('</tbody>');
|
176
|
+
output.append('</table>');
|
177
|
+
?>
|
178
|
+
<?
|
179
|
+
//上記から参照する関数群
|
180
|
+
function escape_html (string) {
|
181
|
+
if(typeof string !== 'string') {
|
182
|
+
return string;
|
183
|
+
}
|
184
|
+
return string.replace(/[&'`"<>]/g, function(match) {
|
185
|
+
return {
|
186
|
+
'&': '&',
|
187
|
+
"'": ''',
|
188
|
+
'`': '`',
|
189
|
+
'"': '"',
|
190
|
+
'<': '<',
|
191
|
+
'>': '>',
|
192
|
+
}[match]
|
193
|
+
});
|
194
|
+
}
|
195
|
+
|
196
|
+
//修正画面リンクを埋め込む関数
|
197
|
+
function getModifyUrl (no, name) {
|
198
|
+
var modifyUrl = url + "/exec?name=modify&no=" + no;
|
199
|
+
return '<a href="' + modifyUrl + '" target="_top">' + name + '</a>';
|
200
|
+
};
|
201
|
+
|
202
|
+
//URLリンクを埋め込む関数
|
203
|
+
function getLink (stringUrl) {
|
204
|
+
var pattern = 'http';
|
205
|
+
if(stringUrl.indexOf(pattern) === 0){
|
206
|
+
return '<a href="' + stringUrl + '" target="_blank">' + stringUrl + '</a>';
|
207
|
+
}else{
|
208
|
+
return stringUrl;
|
209
|
+
}
|
210
|
+
};
|
211
|
+
|
212
|
+
//メールリンクを埋め込む関数
|
213
|
+
function getMailAddress (stringMail) {
|
214
|
+
if(stringMail.indexOf('@') != -1){
|
215
|
+
return '<a href="mailto:' + stringMail + '">' + stringMail + '</a>';
|
216
|
+
}else{
|
217
|
+
return stringMail;
|
218
|
+
}
|
219
|
+
};
|
220
|
+
|
221
|
+
?>
|
222
|
+
</div>
|
223
|
+
</body>
|
224
|
+
</html>
|
225
|
+
```
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|