private static Excel instance;
+ public static Excel getInstance() throws ExcelException {
+ return getInstance(System.out);
+ }
+
public static Excel getInstance(PrintStream out) throws ExcelException {
if(instance == null) {
File extractDir = context.getDataFile("");
if (extractDir == null)
- throw new IOException("Bundle '" + Activator.PLUGIN_ID + " context has no file system support. Cannot extract server executables.");
+ throw new IOException("Bundle '" + Activator.PLUGIN_ID + " context has no file system support. Cannot extract DLLs.");
if (!extractDir.exists())
if (!extractDir.mkdir())
- throw new IOException("Could not create directory '" + extractDir.getCanonicalPath() + "' for storing Balas solver data.");
+ throw new IOException("Could not create directory '" + extractDir.getCanonicalPath() + "' for communicating with Excel.");
return extractDir;
if (!extractDir.exists())
if (!extractDir.mkdir())
- throw new IOException("Could not create directory '" + extractDir.getCanonicalPath() + "' for storing Balas solver data.");
+ throw new IOException("Could not create directory '" + extractDir.getCanonicalPath() + "' for communicating with Excel.");
String asd = "";
ExecEnvironment env = ExecEnvironment.calculate();
private native int setVisible(int handle, boolean value);
private native int close(int handle);
-// private native double getDouble(int handle, int row, int column);
-// private native String getString(int handle, int row, int column);
+ private native double getDouble(int handle, int row, int column);
+ private native String getString(int handle, int row, int column);
final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
});
}
+ public int open2_(final String fileName, final String sheetName) {
+ try {
+ return scheduler.submit(new Callable<Integer>() {
+ @Override
+ public Integer call() throws Exception {
+ return Integer.parseInt(open(fileName, sheetName));
+ }
+ }).get();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return -1;
+ }
+ }
+
public String open_(final String fileName, final String sheetName) {
try {
return scheduler.submit(new Callable<String>() {
}
}
-// public double getDouble_(final int handle, final int row, final int column) {
-// try {
-// return scheduler.submit(new Callable<Double>() {
-// @Override
-// public Double call() throws Exception {
-// return getDouble(handle, row, column);
-// }
-// }).get();
-// } catch (Exception e) {
-// e.printStackTrace();
-// return Double.NaN;
-// }
-// }
-//
-// public String getString_(final int handle, final int row, final int column) {
-// try {
-// return scheduler.submit(new Callable<String>() {
-// @Override
-// public String call() throws Exception {
-// return getString(handle, row, column);
-// }
-// }).get();
-// } catch (Exception e) {
-// e.printStackTrace();
-// return null;
-// }
-// }
+ public double getDouble_(final int handle, final int row, final int column) {
+ try {
+ return scheduler.submit(new Callable<Double>() {
+ @Override
+ public Double call() throws Exception {
+ return getDouble(handle, row, column);
+ }
+ }).get();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return Double.NaN;
+ }
+ }
+
+ public String getString_(final int handle, final int row, final int column) {
+ try {
+ return scheduler.submit(new Callable<String>() {
+ @Override
+ public String call() throws Exception {
+ return getString(handle, row, column);
+ }
+ }).get();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
}