XLoop 是 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 插件)文件?
最佳答案
我尝试运行代码并得到以下输出。
我所要做的就是启动 Excel 并添加 XLLoop 插件。
- 。按
Alt+G
或单击“管理 Excel 加载项”旁边的前往
按钮。 - 。单击“浏览”并提供
xlloop-0.3.2.xll
文件的路径。如果您下载了xlloop-0.3.2.zip
,请将其解压,您将在/xlloop/bin
中找到它
希望有帮助。
编辑:
启动 Excel。
启动服务器(运行
Main
类)并测试公式。
我测试了以下 2 个(在 Excel 公式栏上输入它们并按/按 Enter 键),效果很好。 :)
- =FS("数学.sin", 3.14)
- =FS("数学.随机")
关于java - 在 java 中使用 XLloop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23702980/