Browse Source

fix(bug): copy to excel

bug

fix #319
master
wpxp123456 5 years ago
parent
commit
5cf72ec078
  1. 27
      src/controllers/selection.js

27
src/controllers/selection.js

@ -514,16 +514,25 @@ const selection = {
Store.iscopyself = true; Store.iscopyself = true;
if (!clipboardData) { if (!clipboardData) {
let textarea = $("#luckysheet-copy-content"); // let textarea = $("#luckysheet-copy-content");
textarea.html(cpdata); // textarea.html(cpdata);
textarea.focus(); // textarea.focus();
textarea.select(); // textarea.select();
document.execCommand("selectAll"); // document.execCommand("selectAll");
document.execCommand("Copy"); // document.execCommand("Copy");
// 等50毫秒,keyPress事件发生了再去处理数据 // 等50毫秒,keyPress事件发生了再去处理数据
setTimeout(function () { // setTimeout(function () {
$("#luckysheet-copy-content").blur(); // $("#luckysheet-copy-content").blur();
}, 10); // }, 10);
var oInput = document.createElement('input');
oInput.value = cpdata;
document.body.appendChild(oInput);
oInput.select(); // 选择对象
document.execCommand("Copy");
oInput.style.display='none';
document.body.removeChild(oInput);
} }
else { else {
clipboardData.setData('Text', cpdata); clipboardData.setData('Text', cpdata);

Loading…
Cancel
Save