# wpsnativex **Repository Path**: Kingsoftoffice/wpsnativex ## Basic Information - **Project Name**: wpsnativex - **Description**: WPSNativeX是提供给第三方开发者用native代码来扩展JS接口的技术方案。此代码是使用模型和接入方式的示例代码。详细说明查看README - **Primary Language**: Unknown - **License**: BSD-3-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 14 - **Forks**: 0 - **Created**: 2022-01-20 - **Last Updated**: 2025-03-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Windows platform The operation steps are as follows: For environment preparation, it is recommended to install visual studio 2019. The compilation environment is verified under vs2019 environment, and other versions have not been verified. If other versions are found to have compilation errors, you can leave a message to us for modification. It is recommended to install cmake version 3.15 or above. 1.cd Build 2.cmake ../ - DCMAKE_ BUILD_ TYPE=[Debug|Release] -G "Visual Studio 16" -A Win32 3. Directly compile jsnativedemo SLN or through the command line: msbuild jsnativedemo sln 4. After successful compilation, jsdemo will be generated in build / output directory dll。 5. Use WPS configuration management tool to register DLL, ksomisc Exe is under office6 in the WPS installation directory, Open the CMD window with administrator privileges. If it is the default installation path of WPS, it is usually executed as follows c: & cd C:\Program Files (x86)\Kingsoft\WPS Office\11.8.2.11019\office6 ksomisc -regnativex E:\code\createobject_ 3rdmodule\Build\Output\jsdemo. dll -i false -m decryption 6. Ksomisc register nativex Parameter Description: -Reginvex means to register DLL, and the required parameters -Unregnativex means unregistering the DLL. Required parameters Path indicates the registration path of the DLL. Required parameters -I indicates whether the registered DLL is loaded in process or out of process. It is required. It is recommended to use out of process loading -M represents DLL description information. It is empty by default. Optional parameters. For example, the example commands for registering DLLs are as follows: ksomisc -regnativex E:\nativex\jsdemo. dll -i false -m "this is a jsdemo.dll" An example command to unregister a DLL is as follows: ksomisc -unregnativex E:\nativex\jsdemo. dll -i false -m "this is a testdemo" After the above operations are completed, open build / nativedemo Xlsm, you can call jsdemo in WPS macro editor or WPS add in DLL. Project Description: Wpsnativex is a technical solution for third-party developers to extend JS interface with native code. The number of interfaces provided by jsapi is limited. When the requirements are not met, third-party developers can use native code (c + + / RUBY / python, etc.) to extend the JS interface. After loading the third-party wpsnativex module, they can use their own extended interface in jsapi. For example, third-party developers can use the published SDK to implement complex algorithms (such as encryption and decryption algorithms) and generate DLLs or so, which can be loaded into wpsnativex objects and used in jsapi. The method of modifying the implementation according to the demo access can basically meet the current use scenario. When you encounter problems that cannot be solved by using the demo, you can contact and check https://open.wps.cn/docs/office , the above instructions or contact WPS official customer service QQ number requests help Contribution Description: This code is mainly a code example of using models and methods. It is not an actual landing scenario application. Users need to add application scenarios based on this code. For example, complex encryption algorithms are hidden, only one interface is exposed for JS calls, or some complex JS calculations are implemented in C + +, which can improve efficiency. If you feel that you have achieved a better landing scene, you can go there https://open.wps.cn/docs/office Contact WPS official customer service QQ number to request contribution code WPS personnel will contact you. Windows platform version support: The minimum supported version number of enterprise version is 11.8.2.11019. Download link of enterprise version: https://ep.wps.cn/download Windows 平台 操作步骤如下: 环境准备,建议安装visual studio 2019版,执行编译环境都在vs2019环境下面验证,尚未验证其他版本,如果发现其他版本有编译错误问题,可以留言给我们修改, 建议安装cmake 3.15版本及以上版本。 1.cd Build 2.cmake ../ -DCMAKE_BUILD_TYPE=[Debug|Release] -G "Visual Studio 16" -A Win32 3.直接编JsNativeDemo.sln或者通过命令行:msbuild JsNativeDemo.sln 4.编译成功后会在当前的Build/Output目录生成jsdemo.dll。 5.使用WPS配置管理工具注册dll,ksomisc.exe在WPS的安装目录的office6下面, 使用管理员权限打开cmd窗口,如果是WPS默认安装路径通常如下执行 c: & cd C:\Program Files (x86)\Kingsoft\WPS Office\11.8.2.11019\office6 ksomisc -regnativex dllpath -i false -m decryption 6.ksomisc注册nativex参数说明: -regnativex 表示注册dll,必要参数 -unregnativex 表示取消注册dll,必要参数 path 表示dll的注册路径,必要参数 -i 表示注册dll是在进程内加载还是进程外加载,必须,推荐使用进程外面加载 -m 表示dll描述信息,默认为空,可选参数。 比如注册dll的示例命令如下: ksomisc -regnativex E:\nativex\jsdemo.dll -i false -m "this is a jsdemo.dll" 取消注册dll的示例命令如下: ksomisc -unregnativex E:\nativex\jsdemo.dll -i false -m "this is a testdemo" 以上操作完成后,打开Build/nativeDemo.xlsm,即可在wps宏编辑器中或在wps加载项中调用jsdemo.dll扩展的js接口。 项目说明: WPSNativeX是提供给第三方开发者用native代码来扩展JS接口的技术方案。JSAPI提供的接口个数有限,存在当前提供的JSAPI不满足使用的场景,第三方开发者可以用native代码(c++/ruby/python等)来扩展JS接口,加载第三方WPSNativeX模块后,实现在JSAPI中使用自己扩展的接口。例如第三方开发者可以利用发布的SDK,将复杂的算法(如加密,解密算法)实现并生成dll或者so,提供给WPSNativeX对象加载在JSAPI中使用。 按照demo接入修改实现的方法部分基本上可以满足当前的使用场景,当使用demo遇到解决不了的问题的时候可以联系查看了下https://open.wps.cn/docs/office,上面的使用说明或者联系 WPS官方客服QQ号请求帮助 贡献说明: 此代码主要是使用模型和方式的代码示例,并非实际的落地场景应用,需要开发者基于此代码自行添加应用场景,例如隐藏加解密实现的场景,将复杂的加密算法隐藏,仅提供加解密接口给JS端调用;提高执行效率的场景,将一些复杂的JS计算使用挪到nativex内部采用c++的方式实现;或者其他一些JS端实现有难点,但是采用c++更容易解决的场景都满足要求。基于此demo实现的落地场景想贡献到官方平台的,打开https://open.wps.cn/docs/office 网址,联系WPS官方客服QQ(3253920855 )号联系WPS技术服务人员,或者在开源代码平台留言,我们会定期查看解决大家的问题。 Windows 平台版本支持: 最低支持企业版版本号11.8.2.11019,企业版下载链接:https://ep.wps.cn/download