JSFiddle - React, Tailwind, and code Playground
HTML
<button id="btn">copy</button>
CSS
inputElinputEl document.body.appendChild(inputEl);
document.body.appendChild(inputEl);
AAA BBB 111document.body.appendChild(inputEl);document.body.appendChild(inputEl);A B 1
JavaScript
btn.onclick = function() {
toExcelClipboard(['A', 'B', '1']);
}
function toExcelClipboard(data) {
var inputEl = document.createElement('INPUT');
inputEl.value = data.join('\t');
// элемент нужно добавить в DOM, но display:none применять нельзя
inputEl.setAttribute('style',
'top:-999px;left:0;position:absolute;');
document.body.appendChild(inputEl);
inputEl.select();
document.execCommand('copy');
document.body.removeChild(inputEl);
}