1 parent
9e7d0aeee6
commit
e64a8e9bc5
26 files changed
+1111
-77
No files matched your search
Binary file not shown.
@@ -0,0 +1 @@
|
||||
# WPS 表格自动化
|
||||
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1743477113372" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1505" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M512 1024C229.376 1024 0 794.624 0 512S229.376 0 512 0s512 229.376 512 512-229.376 512-512 512z m0-949.248C271.36 74.752 75.776 271.36 75.776 512S271.36 949.248 512 949.248 949.248 752.64 949.248 512 752.64 74.752 512 74.752z m0 753.664a45.44 45.44 0 0 1-45.056-45.056V444.416c0-25.6 20.48-45.056 45.056-45.056s45.056 19.456 45.056 45.056V783.36A45.44 45.44 0 0 1 512 828.416z m0-474.112c-24.576 0-45.056-20.48-45.056-46.08V240.64c0-24.576 20.48-45.056 45.056-45.056s45.056 20.48 45.056 45.056v67.584c0 25.6-20.48 46.08-45.056 46.08z" p-id="1506"></path></svg>
|
||||
|
After Width: | Height: | Size: 893 B |
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="21px" height="20px" viewBox="0 0 21 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 51.2 (57519) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>从模版新建</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Artboard" transform="translate(-31.000000, -26.000000)">
|
||||
<g id="从模版新建" transform="translate(29.000000, 24.000000)">
|
||||
<g id="Group" stroke-width="1">
|
||||
<g id="新增节" transform="translate(2.000000, 2.000000)">
|
||||
<path d="M19.9587402,10 L18.9587402,10 L18.9587402,2 C18.9587402,1.44771525 18.511025,1 17.9587402,1 L6.0300293,1 C5.47774455,1 5.0300293,1.44771525 5.0300293,2 L5.0300293,18 C5.0300293,18.5522847 5.47774455,19 6.0300293,19 L9.95874023,19 L9.95874023,20 L6.0300293,20 C4.9254598,20 4.0300293,19.1045695 4.0300293,18 L4.0300293,2 C4.0300293,0.8954305 4.9254598,2.02906125e-16 6.0300293,0 L17.9587402,0 C19.0633097,-2.02906125e-16 19.9587402,0.8954305 19.9587402,2 L19.9587402,10 Z" id="Combined-Shape" fill="#404040" fill-rule="nonzero"></path>
|
||||
<path d="M6,1 L4,1 C3.44771525,1 3,1.44771525 3,2 L3,18 C3,18.5522847 3.44771525,19 4,19 L6,19 L6,20 L4,20 C2.8954305,20 2,19.1045695 2,18 L2,2 C2,0.8954305 2.8954305,2.02906125e-16 4,0 L6,0 L6,1 Z" id="Combined-Shape-Copy-2" fill="#404040" fill-rule="nonzero"></path>
|
||||
<path d="M4,1 L2,1 C1.44771525,1 1,1.44771525 1,2 L1,18 C1,18.5522847 1.44771525,19 2,19 L4,19 L4,20 L2,20 C0.8954305,20 1.03797111e-16,19.1045695 0,18 L0,2 C-1.10284431e-16,0.8954305 0.8954305,2.02906125e-16 2,0 L4,0 L4,1 Z" id="Combined-Shape-Copy-3" fill="#404040" fill-rule="nonzero"></path>
|
||||
<path d="M17,15 L20.5,15 C20.7761424,15 21,15.2238576 21,15.5 C21,15.7761424 20.7761424,16 20.5,16 L17,16 L17,19.5 C17,19.7761424 16.7761424,20 16.5,20 C16.2238576,20 16,19.7761424 16,19.5 L16,16 L12.5,16 C12.2238576,16 12,15.7761424 12,15.5 C12,15.2238576 12.2238576,15 12.5,15 L16,15 L16,11.5 C16,11.2238576 16.2238576,11 16.5,11 C16.7761424,11 17,11.2238576 17,11.5 L17,15 Z" id="Combined-Shape" fill="#5789D9"></path>
|
||||
</g>
|
||||
</g>
|
||||
<rect id="Rectangle-15" fill="#404040" x="9" y="6" width="10" height="1"></rect>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
@@ -0,0 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<script type="text/javascript" src="./main.js"></script>
|
||||
</html>
|
||||
<!--这个文件是wps加载项的入口文件,wps在启动时加载这个文件-->
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
//这个函数在整个wps加载项中是第一个执行的
|
||||
function OnAddinLoad(ribbonUI) {
|
||||
if (typeof (window.Application.ribbonUI) != "object") {
|
||||
window.Application.ribbonUI = ribbonUI
|
||||
}
|
||||
|
||||
if (typeof (window.Application.Enum) != "object") { // 如果没有内置枚举值
|
||||
window.Application.Enum = WPS_Enum
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
function OnAction(control) {
|
||||
const eleId = control.Id
|
||||
switch (eleId) {
|
||||
case "btnShowAbout":
|
||||
{
|
||||
alert("关于我们\n\n作者:Jianxin\n\n版本:1.0.0\n\n说明:自动化插件\n\n感谢使用!")
|
||||
}
|
||||
break;
|
||||
case "contactAuthor":
|
||||
{
|
||||
wps.ShowDialog(GetUrlPath() + "/ui/author.html", "联系作者", 400 * window.devicePixelRatio, 400 * window.devicePixelRatio, false)
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
function GetImage(control) {
|
||||
const eleId = control.Id
|
||||
switch (eleId) {
|
||||
case "btnShowAbout":
|
||||
return "images/about.svg"
|
||||
default:
|
||||
;
|
||||
}
|
||||
return "images/newFromTemp.svg"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//在后续的wps版本中,wps的所有枚举值都会通过wps.Enum对象来自动支持,现阶段先人工定义
|
||||
var WPS_Enum = {
|
||||
msoCTPDockPositionLeft: 0,
|
||||
msoCTPDockPositionRight: 2
|
||||
}
|
||||
|
||||
function GetUrlPath() {
|
||||
let e = document.location.toString()
|
||||
return -1 != (e = decodeURI(e)).indexOf("/") && (e = e.substring(0, e.lastIndexOf("/"))), e
|
||||
}
|
||||
/**
|
||||
* 通过wps提供的接口执行一段脚本
|
||||
* @param {*} param 需要执行的脚本
|
||||
*/
|
||||
function shellExecuteByOAAssist(param) {
|
||||
if (wps != null) {
|
||||
wps.OAAssist.ShellExecute(param)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
let wpsInstance = null;
|
||||
|
||||
|
||||
function InvokeFromXbot(param) {
|
||||
// 1. 解析参数, 如果不是字符串, 则转换为字符串, 并用json解析, 解析失败直接retrun
|
||||
if (typeof param !== 'string') {
|
||||
param = JSON.stringify(param);
|
||||
}
|
||||
try {
|
||||
param = JSON.parse(param);
|
||||
} catch (e) {
|
||||
return { msg: '参数解析失败', code: -1 };
|
||||
}
|
||||
|
||||
// 2. 判断是否有method字段, 如果没有直接return
|
||||
if (!param.method) {
|
||||
return { msg: '参数错误', code: -2 };
|
||||
}
|
||||
|
||||
// 3. 获取 method 字段对应的方法和 args 参数
|
||||
let method = param.method;
|
||||
|
||||
let args = null;
|
||||
|
||||
try {
|
||||
args = JSON.parse(param.args);
|
||||
} catch (e) {
|
||||
args = {};
|
||||
}
|
||||
|
||||
|
||||
console.log("method:", method);
|
||||
console.log("args:", args);
|
||||
// confsole.log("args", typeof args);
|
||||
|
||||
// 4. 判断 method 是否为 inject, 如果是则执行注入方法, 其他走默认方法执行调用函数
|
||||
if (method === 'inject') {
|
||||
let code = args.code;
|
||||
console.log("start eval code");
|
||||
console.log(code);
|
||||
console.log(new Function(code)());
|
||||
wpsInstance = new Function(code)(); // 执行并获取返回值
|
||||
console.log("success eval code");
|
||||
return { message: "inject ok", code: 0 }
|
||||
}
|
||||
|
||||
// 5. 判断是否有 wpsInstance, 如果没有直接return
|
||||
if (!wpsInstance) {
|
||||
return { msg: '未注入', code: -3 };
|
||||
}
|
||||
|
||||
// 6. 判断 wpsInstance 是否有 method 方法, 如果没有直接return
|
||||
if (!wpsInstance[method]) {
|
||||
return { msg: '方法不存在', code: -4 };
|
||||
}
|
||||
|
||||
// 7. 执行 wpsInstance 的 method 方法, 并返回结果
|
||||
try {
|
||||
const result = wpsInstance[method](args ?? null);
|
||||
return { msg: '执行成功', code: 0, data: result };
|
||||
} catch (e) {
|
||||
return { msg: '执行失败', code: -5 };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
//这个文件由index.html包含
|
||||
document.write("<script language='javascript' src='js/util.js'></script>");
|
||||
document.write("<script language='javascript' src='js/ribbon.js'></script>");
|
||||
document.write("<script language='javascript' src='js/xbot.js'></script>");
|
||||
@@ -0,0 +1,15 @@
|
||||
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnAddinLoad">
|
||||
<ribbon startFromScratch="false">
|
||||
<tabs>
|
||||
<tab id="wpsAddinTab" label="影刀插件">
|
||||
<group id="btnDemoGroup" label="group1">
|
||||
<button id="btnShowAbout" label="关于插件" onAction="OnAction" getImage="GetImage"
|
||||
visible="true" size="large" />
|
||||
<button id="contactAuthor" label="联系作者" onAction="OnAction"
|
||||
getEnabled="OnGetEnabled" getImage="GetImage" visible="true" size="large" />
|
||||
</group>
|
||||
|
||||
</tab>
|
||||
</tabs>
|
||||
</ribbon>
|
||||
</customUI>
|
||||
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<img class="authImg" src="https://won-link.oss-cn-hangzhou.aliyuncs.com/halo/AuthorWx.png">
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.authImg {
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
position: relative;
|
||||
margin: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
||||
Reference in new issue
Block a user