スプレッドシートで複数選択できるプルダウンを列全体に作成したい

実現したいこと

スプレッドシートで一列すべてのセルに
複数選択可能なプルダウンリストを作成したい

https://teratail.com/questions/iuga34q6week3r
https://qiita.com/Qnoir/items/2ebaa367ed9a75d4ff7b

を参考にしたのですが
スプレッドシートへ書き込むことができていないように見受けられます

前提

html

1<!DOCTYPE html>2<html>3 4<head>5 <base target="_top">6</head>7<style>8 .box select {9 width: 100px;10 }11</style>12 13<body>14 <div class="box">15 <select id="items" multiple>16 <option value="1">1</option>17 <option value="2">2</option>18 <option value="3">3</option>19 <option value="4">4</option>20 <option value="5">5</option>21 </select>22 </div>23 <div>24 <button id="inputdata">入カ</button>25 </div>26 <script>27 document.getElementById("inputdata").addEventListener("click", submit);28 function submit() {29 const items = document.getElementById('items');30 const selectedItems = Array.from(items, (item) => [item.selected, item.value] ).filter(e => e[0]).map(e => e[1]);31 console.log(selectedItems)32 google.script.run.inputValues(selectedItems.join(','),<?= row ?>);33 google.script.host.close();34 }35 </script>36</body>37 38</html>

下から六行目の 末尾

= row ?>)

がおかしいのかと思い数字等に変更をしてみたのですが
スプレッドシートへの反映ができません

該当のソースコード

code.gs

1function showDialog(e){ 2 // ⎾A列以外またはCheckBoxがオフ⏌ならば何もしない。 3 if (e.range.columnStart !== 1 || e.value === 'FALSE') return; 4 // HTMLを組み立て. 5 let html = HtmlService.createTemplateFromFile('index'); 6 html.row = e.range.rowStart; 7 html.col = e.range.columnStart; 8 html = html.evaluate().setWidth(120).setHeight(140); 9 SpreadsheetApp.getUi().showModalDialog(html, '入カ値を選択'); 10} 11 12function inputValues(items, row){ 13 SpreadsheetApp.getActive().getActiveSheet().getRange('C' + row).setValue(items); 14}

index.html

1<!DOCTYPE html> 2<html> 3 4<head> 5 <base target="_top"> 6</head> 7<style> 8 .box select { 9 width: 100px; 10 } 11</style> 12 13<body> 14 <div class="box"> 15 <select id="items" multiple> 16 <option value="1">1</option> 17 <option value="2">2</option> 18 <option value="3">3</option> 19 <option value="4">4</option> 20 <option value="5">5</option> 21 </select> 22 </div> 23 <div> 24 <button id="inputdata">入カ</button> 25 </div> 26 <script> 27 document.getElementById("inputdata").addEventListener("click", submit); 28 function submit() { 29 const items = document.getElementById('items'); 30 const selectedItems = Array.from(items, (item) => [item.selected, item.value] ).filter(e => e[0]).map(e => e[1]); 31 console.log(selectedItems) 32 google.script.run.inputValues(selectedItems.join(','),<?= row ?>); 33 google.script.host.close(); 34 } 35 </script> 36</body> 37 38</html>

試したこと

rowの部分がうまく働いていないのかと思い数字に変更してみたりしました。
お力添えをいただけると幸いです

コメントを投稿

0 コメント