Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(bug): copy to excel
Browse files Browse the repository at this point in the history
bug

fix #319
  • Loading branch information
wpxp123456 committed Dec 11, 2020
1 parent 6d60679 commit 5cf72ec
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/controllers/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,20 +510,29 @@ const selection = {
cpdata += "</tr>";
}
cpdata = '<table data-type="luckysheet_copy_action_table">' + colgroup + cpdata + '</table>';

Store.iscopyself = true;

if (!clipboardData) {
let textarea = $("#luckysheet-copy-content");
textarea.html(cpdata);
textarea.focus();
textarea.select();
document.execCommand("selectAll");
document.execCommand("Copy");
// let textarea = $("#luckysheet-copy-content");
// textarea.html(cpdata);
// textarea.focus();
// textarea.select();
// document.execCommand("selectAll");
// document.execCommand("Copy");

// 等50毫秒,keyPress事件发生了再去处理数据
setTimeout(function () {
$("#luckysheet-copy-content").blur();
}, 10);
// setTimeout(function () {
// $("#luckysheet-copy-content").blur();
// }, 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 {
clipboardData.setData('Text', cpdata);
Expand Down

0 comments on commit 5cf72ec

Please sign in to comment.