What is the best / easiest way to manipulate ActiveX objects in Java?

I want to open and process Excel files using ActiveX. I have had success with Python Win32 Extensions and Groovy Scriptom in other projects, but you need to do this pure Java if possible.

I tried the Java bridge of Java Java code , but it doesn’t seem simple or easy to use, and I couldn’t get it to retrieve the cell values ​​(even if it is the library underlying Scriptom). Are there any alternatives?

+1
source share
4 answers

Jacob really is a tool to work here. I recommend that you take the time to learn a little about how COM and ActiveX work, and I think you will find it easier to use. COM is an achievement, but it is difficult. Packers like VB seem lightweight (for the limited use they work for), but it's not at all easy. I have a great book on learning COM, but right now I don’t have a name ...

You want to know about the IDispatch interface (this is what is developed in most COM interfaces for Excel). This is an unpleasant, unpleasant interface (one of those viral things with which you can do so much that it is impossible to understand what is actually happening), but its study is key.

If you have problems in only one area (i.e., getting the value from the cell), you can grab the source for Scriptom and see what they do (open source, after all!).

Another suggestion is to try to implement some test cases of your code in VBA and make sure that you think correctly about all returned values. When we did Excel automation in one of our Java applications, we implemented the general algorithm from Word VBA, worked through problem cases, etc. After that, passing Java Jacob was pretty simple.

  • K
+4
source

how about http://www.nevaobject.com/_docs/_java2com/java2com.htm - this is commercial, but works better.

0
source

Have you looked at JExcelAPI? Instead of using ActiveX, it is a Java library that directly reads and writes Excel files.

Not an exact answer to your questions, but it can solve the problem just as well, especially if you are looking for a clean Java solution.

0
source

There is also JIntegra , which does a similar thing. Also commercial. And there is JNIWrapper , which does a similar thing. again, also commercial.

0
source

All Articles