I've started looking at XLLoop as I need a way of getting data from a java system into Excel (2010 version).
I've followed the java SimpleServer example on the front page of the website:
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();
}
}
and have successfully been able to integrate simple static java methods into Excel that return one value. E.g.Math.random(), Math.pow(2, 4.45) which both return a single double.
However, I have been unable to integrate any functions that return an array/list of values. For example, in the above we have registered the Maths class (an XLLoop class) for use in Excel. This class contains a static method
public static double[] normalDist(int var0)
The method returns an array of length var0, however when I call this in Excel only one cell is populated with a value, I would have expected var0 cells to have been populated. This seems like a fairly fundamental feature to me, so I'm pretty sure I must be doing something daft.
If there is anyone out there who could help with this it would be greatly appreciated.
I should also mention that I found a similar SO question , linked from a R related SO questions feed. Unfortunately the original SO question has been removed from SO by the poster...