Going Beyond Excel
Remember JCOM is all about COM and not just Excel. Using this toolkit you can control just about any COM object from within Java. Excel is generally the most commonly controlled one, and as such there are nice helper classes to make it easier, but all COM components are available. So controlling other application such as Word or Powerpoint is straightforward too.
Here's an example using Word:
IDispatch wdApp = new IDispatch(rm, "Word.Application");
wdApp.put("Visible", new Boolean(true));
As there is no direct helper class for Word, everything is done through the IDispatch
object (which is exactly what the underlying helper classes do for Excel). The code above will launch a copy of MS Word and make it available for automation through the wdApp
object. You can then play with Word using method such as the 'put' (for setting properties) or 'method' (for calling methods). For example the code above sets the Visible property to true, making the Word app visible.
If you're going to be bound to Windows, there is a wealth of COM components out there to expand your horizons beyond what Java currently offers. Hardware control through the serial or parallel ports can be a snap using the right drivers and now you can do it in Java. And that's just the beginning. With JCOM in your toolbox, the sky is the limit.