使用XLLoop for java
XLLoop是java的开源框架。 例如,我们可以在Excel中使用java中的函数。 以下是非常简单的使用例子:
package org.boris.xlloop.util; import org.boris.xlloop.FunctionServer; import org.boris.xlloop.handler.*; import org.boris.xlloop.reflect.*; public class ServerExample { public static void main(String[] args) throws Exception { // Create function server on the default port FunctionServer fs = new FunctionServer(); // Create a reflection function handler and add the Math methods ReflectFunctionHandler rfh = new ReflectFunctionHandler(); rfh.addMethods("Math.", Math.class); rfh.addMethods("Math.", Maths.class); rfh.addMethods("CSV.", CSV.class); rfh.addMethods("Reflect.", Reflect.class); // Create a function information handler to register our functions FunctionInformationHandler firh = new FunctionInformationHandler(); firh.add(rfh.getFunctions()); // Set the handlers CompositeFunctionHandler cfh = new CompositeFunctionHandler(); cfh.add(rfh); cfh.add(firh); fs.setFunctionHandler(new DebugFunctionHandler(cfh)); // Run the engine System.out.println("Listening on port " + fs.getPort() + "..."); fs.run(); } }
我了解它,一般程序正在工作。 但是,如果我去擅长,它不工作。 我尝试:
=FS("Math.random") =Math.random()
但是我有#NAME?
两次
所以我想我还应该做点什么。 你能告诉我一步一步如何configurationExcel和Java来做到这一点? 我应该如何处理xlloop-0.3.2(Microsoft Excel XLL Add-In)文件?
我试着运行代码,我得到了以下输出。
我所要做的就是启动Excel并添加XLLoop插件。
- 。 按
Alt+G
或单击pipe理Excel加载项旁边的Go
button。 - 。 点击浏览并提供
xlloop-0.3.2.xll
文件的path。 如果你已经下载了xlloop-0.3.2.zip
,解压缩,你会发现它在/xlloop/bin
希望有所帮助。
编辑:
-
启动Excel。
-
启动服务器(运行
Main
类)并testing公式。
我testing了以下2(在Excel公式栏上键入它们并按/按Enter键),它工作正常。 🙂
- = FS(“Math.sin”,3.14)
- = FS( “的Math.random”)
对于遇到同样问题的任何人:您必须将正确的Addin版本添加到您的Excel安装中。
如果您收到错误信息:“文件格式和扩展名不匹配”,则表示您使用的是64位excel和32位XLLoop插件 。
你必须安装一个32位的Excel,或者你必须得到64位版本的XLLoop插件。
我们遇到了同样的问题,并创build了一个64位版本的插件: https : //github.com/PATRONAS/xlloop