直接クリックによるコピーは実現できませんでしたが、スプレッドシート上にコピーボタンのデータを書き込んだHTMLのUIを表示させることで一応実現はできましたので、自己解決方法として記述します。
javascript
1 var copyPage = HtmlService.createTemplateFromFile('index');
2 copyPage.values = template;
3 copyPage.name = "コピー";
4 SpreadsheetApp.getUi().showModalDialog(copyPage.evaluate(), 'コピーしてください');
GASで何らかの処理を行った値をコピーできるようにしたい場合、上記のようにvaluesを用意して、HTML側では<?= values ?>と呼び出す。
html
1 <script>
2 function execCopy(string){
3 var temp = document.createElement('div');
4
5 temp.appendChild(document.createElement('pre')).textContent = string;
6
7 var s = temp.style;
8 s.position = 'fixed';
9 s.left = '-100%';
10
11 document.body.appendChild(temp);
12 document.getSelection().selectAllChildren(temp);
13
14 var result = document.execCommand('copy');
15
16 document.body.removeChild(temp);
17
18 return result;
19 }
20
21 function copy(){
22
23 if(execCopy(<?= values ?>)){
24 alert('コピーできました');
25 }
26 else {
27 alert('このブラウザでは対応していません');
28 }
29 };
30 </script>
31
32 <input type="button" value="コピー" id="button" onclick="copy()">
33
コピー機能はこちらの記事を参考に書きました。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。