Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -15,88 +15,7 @@ html_code='''
|
|
15 |
'''
|
16 |
|
17 |
ht_text='''
|
18 |
-
<
|
19 |
-
<title>吹牛逼</title>
|
20 |
-
<link rel="stylesheet" href="https://powerquery.anvil.app/_/theme/pluginsCss.css" />
|
21 |
-
<link rel="stylesheet" href="https://powerquery.anvil.app/_/theme/plugins.css" />
|
22 |
-
<link rel="stylesheet" href="https://powerquery.anvil.app/_/theme/luckysheet.css" />
|
23 |
-
<link rel="stylesheet" href="https://powerquery.anvil.app/_/theme/iconfont.css" />
|
24 |
-
<script src="https://powerquery.anvil.app/_/theme/plugin.js"></script>
|
25 |
-
<script src="https://mengshukeji.github.io/LuckysheetDemo/luckysheet.umd.js"></script>
|
26 |
-
<script src="https://powerquery.anvil.app/_/theme/xlsx.full.min.js"></script>
|
27 |
-
<script>
|
28 |
-
$(function () {
|
29 |
-
var options = {
|
30 |
-
container: "pq",
|
31 |
-
functionButton: '<button id="download" class="btn btn-primary" style="padding:3px 6px;font-size: 12px;margin-right: 10px;" onclick="FX()">下载</button>',
|
32 |
-
title: "畅心测试",
|
33 |
-
lang: "zh",
|
34 |
-
userInfo: {userName:"畅心",userImage: "https://pbihub.cn/uploads/images/201809/12/44/LWNFWHW7Gj.png"},
|
35 |
-
data: [{"name":"sheet1","index":0,"status":1,"order":0,"color":"#ff0066","row":18,"column":12,"celldata":luckysheet.transToCellData([["维度表","度量值名称","表达式"],])}]
|
36 |
-
}
|
37 |
-
luckysheet.create(options)
|
38 |
-
});
|
39 |
-
|
40 |
-
function FX(){
|
41 |
-
var data = that.luckysheet.getAllSheets()[0].data;
|
42 |
-
var out = XLSX.utils.book_new(),aoa = [[]];
|
43 |
-
|
44 |
-
data.forEach(function(rows, index) {
|
45 |
-
aoa[index] = [];
|
46 |
-
for(var column = 0; column < rows.length - 1; column++) {
|
47 |
-
aoa[index][column] = rows[column] ? rows[column] : '';
|
48 |
-
}
|
49 |
-
});
|
50 |
-
|
51 |
-
var ws = XLSX.utils.aoa_to_sheet(aoa);
|
52 |
-
XLSX.utils.book_append_sheet(out, ws, 'sheet1');
|
53 |
-
|
54 |
-
XLSX.writeFile(out, 'sheet1.xlsx', {});
|
55 |
-
return true;
|
56 |
-
}
|
57 |
-
</script>
|
58 |
-
|
59 |
-
</head>
|
60 |
-
<body>
|
61 |
-
<div id="md" 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>
|
62 |
-
<p style="text-align:center;"> <input style="font-size:16px;" type="file" id="test" name="test" change="demoHandler" /></p>
|
63 |
-
<div id="pq" style="margin:0px;padding:0px;position:absolute;width:100%;left: 0px;top: 50px;bottom: 0px;outline: none;"></div>
|
64 |
-
<script src="https://powerquery.anvil.app/_/theme/luckyexcel.umd.js"></script>
|
65 |
-
<script>
|
66 |
-
function demoHandler(){
|
67 |
-
let upload = document.getElementById("test");
|
68 |
-
let mask = document.getElementById("md");
|
69 |
-
if(upload){
|
70 |
-
|
71 |
-
window.onload = () => {
|
72 |
-
upload.addEventListener("change", function(evt){
|
73 |
-
var files = evt.target.files;
|
74 |
-
if(files==null || files.length==0){alert("没有待加载文件!");return;}
|
75 |
-
|
76 |
-
let name = files[0].name;
|
77 |
-
let suffixArr = name.split("."), suffix = suffixArr[suffixArr.length-1];
|
78 |
-
if(suffix!="xlsx"){alert("目前只支持xlsx文档导入!");return;}
|
79 |
-
LuckyExcel.transformExcelToLucky(files[0], function(exportJson, luckysheetfile){
|
80 |
-
|
81 |
-
if(exportJson.sheets==null || exportJson.sheets.length==0){alert("读取失败, 目前不支持xls文件!");return;}
|
82 |
-
console.log(exportJson, luckysheetfile);
|
83 |
-
window.luckysheet.destroy();
|
84 |
-
|
85 |
-
window.luckysheet.create({
|
86 |
-
container: 'pq',
|
87 |
-
showinfobar:false,
|
88 |
-
data:exportJson.sheets,
|
89 |
-
title:exportJson.info.name,
|
90 |
-
userInfo:exportJson.info.name.creator
|
91 |
-
});
|
92 |
-
});
|
93 |
-
});
|
94 |
-
}
|
95 |
-
}
|
96 |
-
}
|
97 |
-
demoHandler();
|
98 |
-
</script>
|
99 |
-
</body>
|
100 |
'''
|
101 |
|
102 |
demo = gr.Blocks()
|
|
|
15 |
'''
|
16 |
|
17 |
ht_text='''
|
18 |
+
<iframe width="700" height="800" frameborder="0" scrolling="no" src="https://dyrscomcn-my.sharepoint.com/personal/huangcaiguang_dyrs_com_cn/_layouts/15/Doc.aspx?sourcedoc={6d3da844-5b54-473b-a32a-08659600d015}&action=embedview&AllowTyping=True&ActiveCell='Sheet1'!A1&wdInConfigurator=True&wdInConfigurator=True&edesNext=false&ejss=false"></iframe>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
'''
|
20 |
|
21 |
demo = gr.Blocks()
|