Spaces:
Running
Running
Upload cx.js
Browse files- wps-test/js/cx.js +44 -0
wps-test/js/cx.js
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function fx(n){
|
2 |
+
var a=1,b=1;
|
3 |
+
for(i=2;i<=n;i++){[a,b]=[b,a+b]};
|
4 |
+
return a
|
5 |
+
}
|
6 |
+
function onbuttonclick(idStr)
|
7 |
+
{
|
8 |
+
switch(idStr)
|
9 |
+
{
|
10 |
+
case "fn":{
|
11 |
+
let curSheet = wps.EtApplication().ActiveSheet;
|
12 |
+
if (curSheet){
|
13 |
+
curSheet.Cells.Item(1, 1).Formula="执一以为天下式" + curSheet.Cells.Item(1, 1).Formula
|
14 |
+
}
|
15 |
+
break;
|
16 |
+
}
|
17 |
+
case "fb":{
|
18 |
+
const doc = wps.EtApplication().ActiveSheet;
|
19 |
+
if (doc){
|
20 |
+
const x=wps.EtApplication().InputBox('请输入需要生成的项序号','测试','5',200,200)
|
21 |
+
doc.Cells.Item(1, 1).Formula=fx(Number(x))
|
22 |
+
}
|
23 |
+
break;
|
24 |
+
}
|
25 |
+
case "fn2":{
|
26 |
+
const doc2 = wps.EtApplication().ActiveSheet
|
27 |
+
if (doc2){
|
28 |
+
doc2.Cells.Item(1, 1).Formula=document.querySelector("#畅心 > img").src
|
29 |
+
}
|
30 |
+
break;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
window.onload = ()=>{
|
36 |
+
var xmlReq = WpsInvoke.CreateXHR();
|
37 |
+
var url = location.origin + "/.debugTemp/NotifyDemoUrl"
|
38 |
+
xmlReq.open("GET", url);
|
39 |
+
xmlReq.onload = function (res) {
|
40 |
+
var node = document.getElementById("DemoSpan");
|
41 |
+
window.document.getElementById("DemoSpan").innerHTML = res.target.responseText;
|
42 |
+
};
|
43 |
+
xmlReq.send();
|
44 |
+
}
|