output.. = bin/
bin.includes = META-INF/,\
.,\
- SimanticsExcel.dll
+ SimanticsExcel.dll,\
+ scl/
-//#include "stdafx.h"
-
-//#ifndef _UNICODE
-//#define _UNICODE
-//#endif
-
#include <sstream>
#include <map>
-//#include <cmath>
-//#include <TCHAR.H>
+#include <stdio.h>
+#include <tchar.h>
+#include <cstring>
+#include <atlstr.h>
using namespace std;
-#import "c:/program files (x86)/common files/microsoft shared/office12/mso.dll" \
- rename( "RGB", "MSORGB" )
-
-using namespace Office;
-
-#import "c:/program files (x86)/common files/microsoft shared/vba/vba6/vbe6ext.olb" \
-
-using namespace VBIDE;
+// mso.dll
+#import "libid:{2df8d04c-5bfa-101b-bde5-00aa0044de52}" auto_rename
+// vb6ext.olb
+#import "libid:{0002e157-0000-0000-c000-000000000046}" auto_rename
+// excel.exe
+#import "libid:{00020813-0000-0000-c000-000000000046}" auto_rename
-#import "c:/program files (x86)/microsoft office/office12/excel.exe" \
- rename( "DialogBox", "ExcelDialogBox" ) \
- rename( "RGB", "ExcelRGB" ) \
- rename( "CopyFile", "ExcelCopyFile" ) \
- rename( "ReplaceText", "ExcelReplaceText" )
+using namespace Excel;
#include "jni2.h"
#define SIMANTICS_DEBUG(...)
-using namespace std;
-using namespace Excel;
+//using namespace std;
+//using namespace Office;
-map<int, Excel::_WorksheetPtr> handles;
+map<int, _WorksheetPtr> handles;
static int handleCounter = 1;
void replace(std::string &s, const std::string &s1, const std::string &s2) {
}
-/**
+
JNIEXPORT jdouble JNICALL Java_org_simantics_excel_Excel_getDouble(JNIEnv *env, jobject, jint handle, jint row, jint column) {
SIMANTICS_DEBUG("getDouble(%d, %d)\r\n", row, column);
}
JNIEXPORT jstring JNICALL Java_org_simantics_excel_Excel_getString(JNIEnv *env, jobject, jint handle, jint row, jint column) {
-
+ USES_CONVERSION;
//string val = getString(env, value);
SIMANTICS_DEBUG("getString(%d, %d)\r\n", row, column);
Excel::RangePtr range = sheet->Cells;
if(!range) return NULL;
- variant_t val = range->Item[row+1][column+1];
- if (val.vt != VT_NULL) { // val.vt seems to be always VT_DISPATCH.
- try {
+ _bstr_t val = _bstr_t(range->Item[row + 1][column + 1]);
+ //if (val.vt != VT_NULL) { // val.vt seems to be always VT_DISPATCH.
+ //try {
//this call will crash the application, if the cell is empty!
- _bstr_t bstrt = val;
- TCHAR text[1024];
+ //_bstr_t bstrt = val;
+ //std::string text(val);
+ //CString text(val);
+ //text.
+ //TCHAR text[1024];
// TODO: this uses wide character (16-bit) while NewStringUTF expext regular character (8-bit), hence Java gets only the fisrt charater of the whole string.
- _stprintf(text, _T("%s"), (LPCTSTR)bstrt);
+ //_stprintf(text, _T("%s"), (LPCTSTR)bstrt);
//const char *text = bstrt;
SIMANTICS_DEBUG("%s\r\n",text);
-
- // this code returns "??" for all cells.
- //BSTR bstr = val.bstrVal;
- //const char *text = _com_util::ConvertBSTRToString(bstr);
- jstring ret = env->NewStringUTF((const char*)text);
- delete[] text;
- return ret;
- } catch (...) {
- return NULL;
- }
- }
- SIMANTICS_DEBUG("%d\r\n",val.vt);
- return NULL;
+ string text(val);
+
+
+ return env->NewStringUTF(text.c_str());
+
+ //} catch (...) {
+ // return NULL;
+ //}
+ //}
+ //SIMANTICS_DEBUG("%d\r\n",val.vt);
+ //return NULL;
}
-*/
\ No newline at end of file
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimanticsExcel", "SimanticsExcel.vcproj", "{E106958A-412F-4782-81CD-DF380D66BA6B}"
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.40629.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimanticsExcel", "SimanticsExcel.vcxproj", "{E106958A-412F-4782-81CD-DF380D66BA6B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E106958A-412F-4782-81CD-DF380D66BA6B}.Debug|Win32.ActiveCfg = Debug|Win32
{E106958A-412F-4782-81CD-DF380D66BA6B}.Debug|Win32.Build.0 = Debug|Win32
- {E106958A-412F-4782-81CD-DF380D66BA6B}.Release|Win32.ActiveCfg = Release|Win32
- {E106958A-412F-4782-81CD-DF380D66BA6B}.Release|Win32.Build.0 = Release|Win32
+ {E106958A-412F-4782-81CD-DF380D66BA6B}.Release|Win32.ActiveCfg = Release|x64
+ {E106958A-412F-4782-81CD-DF380D66BA6B}.Release|Win32.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E106958A-412F-4782-81CD-DF380D66BA6B}</ProjectGuid>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
+ <UseOfMfc>false</UseOfMfc>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v120</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
- <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
- <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</GenerateManifest>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
- <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
- <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
+ <_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <OutDir>$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir>$(Configuration)\</IntDir>
+ <LinkIncremental>true</LinkIncremental>
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <OutDir>$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir>$(Configuration)\</IntDir>
+ <LinkIncremental>false</LinkIncremental>
+ <GenerateManifest>false</GenerateManifest>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<FloatingPointExceptions>true</FloatingPointExceptions>
- <PrecompiledHeader>
- </PrecompiledHeader>
+ <PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>false</MkTypLibCompatible>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <FloatingPointExceptions>true</FloatingPointExceptions>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <ShowProgress>LinkVerboseLib</ShowProgress>
+ <ModuleDefinitionFile>.\SimanticsExcel.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>false</MkTypLibCompatible>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader />
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ <AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <ModuleDefinitionFile>.\SimanticsExcel.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>false</MkTypLibCompatible>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
- <TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="SimanticsExcel.cpp" />
</ItemGroup>
<ItemGroup>
- <None Include="SimanticsExcel.def" />
- <None Include="res\SimanticsExcel.rc2" />
<None Include="Debug\excel.tlh" />
<None Include="Debug\mso.tlh" />
- <None Include="ReadMe.txt" />
<None Include="Debug\vbe6ext.tlh" />
+ <None Include="res\SimanticsExcel.rc2" />
+ <None Include="SimanticsExcel.def" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="jni2.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
JNIEXPORT jint JNICALL Java_org_simantics_excel_Excel_setName(JNIEnv *env, jobject, jint handle, jint row, jint column, jstring value);
JNIEXPORT jint JNICALL Java_org_simantics_excel_Excel_setVisible(JNIEnv *env, jobject, jint handle, jboolean value);
JNIEXPORT jint JNICALL Java_org_simantics_excel_Excel_close(JNIEnv *env, jobject, jint handle);
-
-//JNIEXPORT jstring JNICALL Java_org_simantics_excel_Excel_getString(JNIEnv *env, jobject, jint handle, jint row, jint column);
-//JNIEXPORT jdouble JNICALL Java_org_simantics_excel_Excel_getDouble(JNIEnv *env, jobject, jint handle, jint row, jint column);
+JNIEXPORT jstring JNICALL Java_org_simantics_excel_Excel_getString(JNIEnv *env, jobject, jint handle, jint row, jint column);
+JNIEXPORT jdouble JNICALL Java_org_simantics_excel_Excel_getDouble(JNIEnv *env, jobject, jint handle, jint row, jint column);
#ifdef __cplusplus
}
--- /dev/null
+importJava "org.simantics.excel.Excel" where
+
+ data Excel
+
+ @JavaName "getInstance"
+ excelInstance :: () -> <Proc> Excel
+
+ @JavaName "open2_"
+ openExcelSheet :: Excel -> String -> String -> <Proc> Integer
+ @JavaName "close_"
+ closeExcelSheet :: Excel -> Integer -> <Proc> ()
+ @JavaName "setString_"
+ setExcelString :: Excel -> Integer -> Integer -> Integer -> String -> <Proc> Integer
+ @JavaName "getString_"
+ getExcelString :: Excel -> Integer -> Integer -> Integer -> <Proc> String
+ @JavaName "setDouble_"
+ setExcelDouble :: Excel -> Integer -> Integer -> Integer -> Double -> <Proc> Integer
+ @JavaName "getDouble_"
+ getExcelDouble :: Excel -> Integer -> Integer -> Integer -> <Proc> Double
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;
+ }
+ }
}