-
Notifications
You must be signed in to change notification settings - Fork 0
/
玩具.html
138 lines (127 loc) · 7.76 KB
/
玩具.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>畅心测试文档</title>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet/dist/plugins/css/pluginsCss.css' />
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet/dist/plugins/plugins.css' />
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet/dist/css/luckysheet.css' />
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet/dist/assets/iconfont/iconfont.css' />
<script src="https://cdn.jsdelivr.net/npm/luckysheet/dist/plugins/js/plugin.js"></script>
<script src="https://cdn.jsdelivr.net/npm/luckysheet/dist/luckysheet.umd.js"></script>
<script>
$(function () {
var options = {
container: 'luckysheet',
title: '畅心测试',
lang: 'zh',
userInfo: {userName:'畅心',userImage: 'https://pbihub.cn/uploads/images/201809/12/44/LWNFWHW7Gj.png'}
}
options.data= [{"name":"吹水","index":0,"status":1,"order":0,"row":36,"column":10,"celldata":[{"r":0,"c":0,"v":{"ct":{fa:"General",t:"g"},"m":"畅心","v":"执一以为天下式","f":"=SUM(1)"}}]},
{"name":"踢皮球","index":1,"order":1,"color":"#ff0066","celldata":[]}]
luckysheet.create(options)
});
</script>
</head>
<body>
<div id="lucky-mask-demo" style="position: absolute;z-index: 1000000;left: 0px;top: 0px;bottom: 0px;right: 0px; background: rgba(255, 255, 255, 0.8); text-align: center;font-size: 40px;align-items:center;justify-content: center;display: none;">Downloading</div>
<p style="text-align:center;"> <input style="font-size:16px;" type="file" id="Luckyexcel-demo-file" name="Luckyexcel-demo-file" change="demoHandler" />加载文档: <select style="height: 27px;top: -2px;position: relative;" id="Luckyexcel-select-demo"> <option value="">请选择一个加载文档</option> <option value="https://raw.githubusercontent.com/tt0203/changxin/master/Embedded.xlsx">吹牛逼</option> </select> <a href="javascript:void(0)" id="Luckyexcel-downlod-file">下载所选文档</a></p>
<div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;left: 0px;top: 50px;bottom: 0px;outline: none;"></div>
<script src="https://cdn.jsdelivr.net/npm/luckyexcel/dist/luckyexcel.umd.js"></script>
<!-- <script type="module">
import l from './luckyexcel.js';
console.info('=====',l)
// window.onload = () => {
// let upload = document.getElementById("file");
// upload.addEventListener("change", function(evt){
// var files = evt.target.files;
// importFile(files[0]);
// });
// }
</script> -->
<script>
function demoHandler(){
let upload = document.getElementById("Luckyexcel-demo-file");
let selectADemo = document.getElementById("Luckyexcel-select-demo");
let downlodDemo = document.getElementById("Luckyexcel-downlod-file");
let mask = document.getElementById("lucky-mask-demo");
if(upload){
window.onload = () => {
upload.addEventListener("change", function(evt){
var files = evt.target.files;
if(files==null || files.length==0){
alert("No files wait for import");
return;
}
let name = files[0].name;
let suffixArr = name.split("."), suffix = suffixArr[suffixArr.length-1];
if(suffix!="xlsx"){
alert("目前只支持xlsx文档导入!");
return;
}
LuckyExcel.transformExcelToLucky(files[0], function(exportJson, luckysheetfile){
if(exportJson.sheets==null || exportJson.sheets.length==0){
alert("读取失败, 目前不支持xls文件!");
return;
}
console.log(exportJson, luckysheetfile);
window.luckysheet.destroy();
window.luckysheet.create({
container: 'luckysheet', //luckysheet is the container id
showinfobar:false,
data:exportJson.sheets,
title:exportJson.info.name,
userInfo:exportJson.info.name.creator
});
});
});
selectADemo.addEventListener("change", function(evt){
var obj = selectADemo;
var index = obj.selectedIndex;
var value = obj.options[index].value;
var name = obj.options[index].innerHTML;
if(value==""){
return;
}
mask.style.display = "flex";
LuckyExcel.transformExcelToLuckyByUrl(value, name, function(exportJson, luckysheetfile){
if(exportJson.sheets==null || exportJson.sheets.length==0){
alert("读取失败, 目前不支持xls文件!");
return;
}
console.log(exportJson, luckysheetfile);
mask.style.display = "none";
window.luckysheet.destroy();
window.luckysheet.create({
container: 'luckysheet', //luckysheet is the container id
showinfobar:false,
data:exportJson.sheets,
title:exportJson.info.name,
userInfo:exportJson.info.name.creator
});
});
});
downlodDemo.addEventListener("click", function(evt){
var obj = selectADemo;
var index = obj.selectedIndex;
var value = obj.options[index].value;
if(value.length==0){
alert("请从下拉列表选择一个文档!");
return;
}
var elemIF = document.getElementById("Lucky-download-frame");
if(elemIF==null){
elemIF = document.createElement("iframe");
elemIF.style.display = "none";
elemIF.id = "Lucky-download-frame";
document.body.appendChild(elemIF);
}
elemIF.src = value;
});
}
}
}
demoHandler();
</script>
</body>
</html>