質問編集履歴

1

ソースを追加

2020/07/03 12:49

投稿

rena_168
rena_168

スコア73

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