|
List Info
Thread: Javamail Digest, Vol 8, Issue 7
|
|
| Javamail Digest, Vol 8, Issue 7 |

|
2006-11-10 17:43:50 |
|
Check out Jacob:Java-COM Bridge. The samples in the package will show you how to load and invoke a COM/ActiveX object (in your case, use the excel COM component).
Here is the example from the site, should give a general idea.
ActiveXComponent xl = new ActiveXComponent("Excel.Application"); Object xlo = xl.getObject(); try { System.out.println
("version="+xl.getProperty("Version")); System.out.println("version="+Dispatch.get(xlo, "Version")); xl.setProperty("Visible", new Variant(true)); Object workbooks =
xl.getProperty("Workbooks").toDispatch(); Object workbook = Dispatch.get(workbooks,"Add").toDispatch(); Object sheet = Dispatch.get(workbook,"ActiveSheet").toDispatch();
Object a1 = Dispatch.invoke(sheet, "Range", Dispatch.Get, new Object[] {"A1"}, new int[1]).toDispatch(); Object a2 =
Dispatch.invoke(sheet, "Range", Dispatch.Get, new Object[] {"A2"}, new int[1]).toDispatch(); Dispatch.put(a1, "Value", "
123.456"); Dispatch.put(a2, "Formula", "=A1*2"); System.out.println("a1 from excel:"+Dispatch.get(a1, "Value")); System.out.println("a2 from excel:"+Dispatch.get(a2, "Value"));
Variant f = new Variant(false); Dispatch.call(workbook, "Close", f); } catch (Exception e) { e.printStackTrace(); } finally { xl.invoke("Quit", new Variant[] {});
}
Hope this helps
Alok
On 11/10/06, javamail-request pjug.org">javamail-request pjug.org < javamail-request pjug.org">javamail-request pjug.org
> wrote: > Send Javamail mailing list submissions to > javamail pjug.org">javamail pjug.org > > To subscribe or unsubscribe via the World Wide Web, visit >
http://www.pjug.org/mailman/listinfo/javamail_pjug.org > or, via email, send a message with subject or body 'help' to > javamail-request pjug.org">
javamail-request pjug.org > > You can reach the person managing the list at > javamail-owner pjug.org">javamail-owner pjug.org > > When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Javamail digest..." > > > PJUG Javamail Digest > > Today's Topics: > > 1. Re: Java Windows Programming Primer (Mike Brady) > 2. Seattle anyone? (Thomas, Damon)
> > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 9 Nov 2006 11:20:24 -0800 (PST) > From: Mike Brady < mikejbrady yahoo.com">
mikejbrady yahoo.com> > Subject: Re: [PJUG Javamail] Java Windows Programming Primer > To: Javamail pjug.org">Javamail pjug.org > Message-ID: < 20061109192024.9429.qmail web30813.mail.mud.yahoo.com">
20061109192024.9429.qmail web30813.mail.mud.yahoo.com> > Content-Type: text/plain; charset="iso-8859-1" > > Hi Michael and Matt, > > Sorry so slow on the reply. I am responding on the digest. I will reply quicker if you cc me on the reply (
mikejbrady yahoo.com">mikejbrady yahoo.com). > > JNI Wrapper looks like a good product, and just might do the trick. At first glance, it looks like it enables COM interactions from inside a Java program (your chore #1), but not necessarily Java interactions inside a Windows application (your chores #2, 3, & 4). Dig deeper, it just might solve those too.
> > Another option I am aware of, though I have not used it personally, is the Sun ActiveX Bridge. It should solve chores #2, 3, & 4. Links: > >
http://java.sun.com/products/javabeans/ActiveXtools.html > http://java.sun.com/j2se/1.4.2/docs/guide/beans/axbridge/developerguide/index.html
> http://java.sun.com/products/plugin/1.3/activex.faq.html > > - You would probably implement the bridge on a facade class that does everything you need to do since every exported bean requires a separate jar and a separate dll.
> - You would naturally have to control this from within Excel using VBA, though you can define events on your control that you can handle in VB, and therefore give Java a means for driving functionality (putting data in cells, etc).
> - Address chore #2 by having VB script on the button that calls your java component. > - You can have a UI component as the example illustrates (I believe this is what you wanted in your chore #4). Therefore, you should not have trouble displaying the java component inside the ActiveX container. I would expect that to include java message boxes (chore #3).
> > Hope this helps, > Mike Brady > > ----------------------- > > Date: Thu, 9 Nov 2006 00:14:23 -0600 > From: "Matt Tucker" < matt jivesoftware.com">
matt jivesoftware.com> > Subject: Re: [PJUG Javamail] Java Windows Programming Primer > To: < MichaelMcDonald Freightliner.com">MichaelMcDonald Freightliner.com>, > < michaelandrewphoenix gmail.com">
michaelandrewphoenix gmail.com> > Cc: javamail pjug.org">javamail pjug.org > Message-ID: > < E1F190DAC247C64FAA46B38316FA151D053CA668 EX-101.mail.navisite.com">
E1F190DAC247C64FAA46B38316FA151D053CA668 EX-101.mail.navisite.com> > Content-Type: text/plain; charset="us-ascii" > > Check out JNIWrapper: > >
http://www.jniwrapper.com/pages/home > > In particular, they have a new product called JExcel that may do exactly > what you're looking for. > > Regards, > Matt > >
> ________________________________ > > From: javamail-bounces pjug.org">javamail-bounces pjug.org > [mailto: javamail-bounces pjug.org">javamail-bounces pjug.org
] On Behalf Of > MichaelMcDonald Freightliner.com">MichaelMcDonald Freightliner.com > Sent: Wednesday, November 08, 2006 4:30 PM > To: michaelandrewphoenix gmail.com">
michaelandrewphoenix gmail.com > Cc: javamail pjug.org">javamail pjug.org > Subject: Re: [PJUG Javamail] Java Windows Programming Primer > > > Thanks for the reply Michael. I was kind of wondering too if
> java could be made usable in a pull from Excel fashion and I plan on > researching a bit more on that subject. If nothing else I should be > able to build a standard exe file with java and then have have a button
> in Excel run a VB sub to use the shell command to run my java created > exe. Making the code "seem" like it's embedded though might be tough. > > Thanks also for the Runtime class suggestion. I will look into
> it. > > ________________________________ > > From: Michael Phoenix [mailto: michaelandrewphoenix gmail.com">michaelandrewphoenix gmail.com] > Sent: Wednesday, November 08, 2006 4:10 PM
> To: Michael McDonald > Cc: javamail pjug.org">javamail pjug.org > Subject: Re: [PJUG Javamail] Java Windows Programming Primer > > > i've got a couple of ideas that I have listed below each of your
> queries that I am able to address. > > > On 11/8/06, MichaelMcDonald freightliner.com">MichaelMcDonal | |