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?
两次
所以我想我应该做点什么。你能一步一步地告诉我如何配置excel和java来做到这一点吗?我该怎么办xlloop-0.3.2(Microsoft Excel XLL加载项)文件?
答案 0 :(得分:2)
我尝试运行代码,但得到了以下输出。
我所要做的就是启动Excel并添加XLLoop插件。
Alt+G
或点击管理Excel加载项旁边的Go
按钮。xlloop-0.3.2.xll
文件的路径。如果您已下载xlloop-0.3.2.zip
,请将其解压缩,然后您会在/xlloop/bin
希望有所帮助。
启动Excel。
启动服务器(运行Main
类)并测试公式。
我测试了以下2个(在Excel公式栏上键入它们并点击/按Enter键)它运行正常。 :)
答案 1 :(得分:0)
对于遇到同样问题的人: 您必须在Excel安装中添加正确的Addin版本。
如果您收到错误消息:&#34;文件格式和扩展程序不匹配。&#34;,则表示您使用的是 64位excel < / strong>和 32位XLLoop插件。
您必须安装32位Excel,否则必须获得64位版本的XLLoop插件。
我们遇到了同样的问题,并创建了一个64位版本的插件:https://github.com/PATRONAS/xlloop