From 5cf72ec0781f0e3b2ddc77eac228812507ce66a2 Mon Sep 17 00:00:00 2001
From: wpxp123456 <2677556700@qq.com>
Date: Fri, 11 Dec 2020 11:16:16 +0800
Subject: [PATCH] fix(bug): copy to excel
bug
fix #319
---
src/controllers/selection.js | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/src/controllers/selection.js b/src/controllers/selection.js
index 7d7d4babb..840086602 100644
--- a/src/controllers/selection.js
+++ b/src/controllers/selection.js
@@ -510,20 +510,29 @@ const selection = {
cpdata += "";
}
cpdata = '
' + colgroup + cpdata + '
';
-
+
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);