List Info

Thread: Javamail Digest, Vol 8, Issue 7




Javamail Digest, Vol 8, Issue 7
user name
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-requestpjug.org">javamail-requestpjug.org < javamail-requestpjug.org">javamail-requestpjug.org > wrote:
>; Send Javamail mailing list submissions to
>&nbsp; &nbsp; &nbsp;   ; javamailpjug.org">javamailpjug.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>  ; &nbsp; &nbsp; &nbsp; http://www.pjug.org/mailman/listinfo/javamail_pjug.org
> or, via email, send a message with subject or body 'help' to
>&nbsp; &nbsp; &nbsp;   ; javamail-requestpjug.org"> javamail-requestpjug.org
>
> You can reach the person managing the list at
>&nbsp; &nbsp; &nbsp;   ; javamail-ownerpjug.org">javamail-ownerpjug.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Javamail digest...&quot;
>
>
> PJUG Javamail Digest
>;
> Today's Topics:
&gt;
; &nbsp; 1. Re: Java Windows Programming Primer (Mike Brady)
>; &nbsp; &nbsp;2. Seattle anyone? (Thomas, Damon)
&gt;
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 9 Nov 2006 11:20:24 -0800 (PST)
> From: Mike Brady < mikejbradyyahoo.com"> mikejbradyyahoo.com>
> Subject: Re: [PJUG Javamail] Java Windows Programming Primer
>; To: Javamailpjug.org">Javamailpjug.org
> Message-ID: < 20061109192024.9429.qmailweb30813.mail.mud.yahoo.com"> 20061109192024.9429.qmailweb30813.mail.mud.yahoo.com>
> Content-Type: text/plain; charset=&quot;iso-8859-1"
&gt;
> 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 ( mikejbradyyahoo.com">mikejbradyyahoo.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
&gt; 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&quot; < mattjivesoftware.com"> mattjivesoftware.com>
> Subject: Re: [PJUG Javamail] Java Windows Programming Primer
>; To: < MichaelMcDonaldFreightliner.com">MichaelMcDonaldFreightliner.com>,
; < michaelandrewphoenixgmail.com"> michaelandrewphoenixgmail.com>
> Cc: javamailpjug.org">javamailpjug.org
> Message-ID:
; < E1F190DAC247C64FAA46B38316FA151D053CA668EX-101.mail.navisite.com"> E1F190DAC247C64FAA46B38316FA151D053CA668EX-101.mail.navisite.com>
&gt; Content-Type: text/plain; charset=&quot;us-ascii"
>;
> Check out JNIWrapper:
>
> http://www.jniwrapper.com/pages/home
>
> In particular, they have a new product called JExcel that may do exactly
&gt; what you're looking for.
>
> Regards,
&gt; Matt
>
>
> ________________________________
>
; From: javamail-bouncespjug.org">javamail-bouncespjug.org
> [mailto: javamail-bouncespjug.org">javamail-bouncespjug.org ] On Behalf Of
> MichaelMcDonaldFreightliner.com">MichaelMcDonaldFreightliner.com
>; &nbsp;Sent: Wednesday, November 08, 2006 4:30 PM
>&nbsp; To: michaelandrewphoenixgmail.com"> michaelandrewphoenixgmail.com
 Cc: javamailpjug.org">javamailpjug.org
> &nbsp;Subject: Re: [PJUG Javamail] Java Windows Programming Primer
>;
>
; Thanks for the reply Michael.&nbsp; 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.&nbsp; If nothing else I should be
> able to build a standard exe file with java and then have have a button
&gt; in Excel run a VB sub to use the shell command to run my java created
&gt; exe.  Making the code "seem" like it's embedded though might be tough.
>;
; Thanks also for the Runtime class suggestion. &nbsp;I will look into
> it.
>
> ________________________________
>
; From: Michael Phoenix [mailto: michaelandrewphoenixgmail.com">michaelandrewphoenixgmail.com]
; Sent: Wednesday, November 08, 2006 4:10 PM
>&nbsp; To: Michael McDonald
&gt; &nbsp;Cc: javamailpjug.org">javamailpjug.org
> &nbsp;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.
&gt;
>
; On 11/8/06, MichaelMcDonaldfreightliner.com">MichaelMcDonaldfreightliner.com
>; < MichaelMcDonaldfreightliner.com"> MichaelMcDonaldfreightliner.com > wrote:
>;
;  Hello PJUG,
>
; &nbsp; &nbsp;  I am hunting for some tutorials on how to declare
&gt; and assign windows objects in Java. ; I am swimming in loosely related
&gt; information so any recommendations of literature people have liked on
> the subject would be appreciated. &nbsp;Some examples of examples I would
> like to find are:
>
;  1) Have a Java app launch Microsoft Excel in Windows XP,
> create a new workbook, and assign value 3 to cell B2 on sheet1.
&gt;
>
; You can use the Runtime class's exec method to launch Microsoft
> Excel. It is possible that you could perform the other actions by using
>; command line arguments with the Excel executable to do the other
> functions, but I'm not sure as I haven't worked with Excel for awhile.
&gt; If none of the gurus on this list have a better idea, also consider
> writing a VB app to perform those functions and launch it from java with
> the exec method.
&gt;
>
>
;  2) Assign a user created button in Excel to launch a
> Hello World Java program.
>
>
; I'm not sure this can be done. I think that buttons in Office
>; applications can only launch VBA macros.
&gt;
>
>
;  3) Have a Java app draw a standard Windows messagebox.
>
>
>
; Look at the AWT or swing packages. They enable you to build the
> equivalent of a windows message box pretty easily.
&gt;
>
>
;  4) Embed a java class inside an Excel workbook
>
>
; Again, I don't think this is doable.
&gt;
>
>
; &nbsp; &nbsp; &nbsp;  Hopefully, SOME of these are easily accomplished.
> I know these are mickey mouse questions to some of you, but my name is
> Mikey, not Mickey!&nbsp; :P
>
>
;  Thanks in Advance,
&gt;
;  Michael
&gt;
>
>
> ---------------------------------
> Access over 1 million songs - Yahoo! Music Unlimited.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: /pipermail/javamail_pjug.org/attachments/20061109/d2c96d29/attachment-0001.html
>
> ------------------------------
>
> Message: 2
> Date: Thu, 9 Nov 2006 19:35:48 -0500
> From: "Thomas, Damon"; < Damon.Thomascdicorp.com">Damon.Thomascdicorp.com>
> Subject: [PJUG Javamail] Seattle anyone?
&gt; To: < javamailpjug.org">javamailpjug.org&gt;
> Message-ID:
; &nbsp; &nbsp; &nbsp;  < BBD6B8F34506EB48BC74838B31919924B716F8PHL17MSEX2K3-02.CDI.CDICorp.net">BBD6B8F34506EB48BC74838B31919924B716F8PHL17MSEX2K3-02.CDI.CDICorp.net >
>
> Content-Type: text/plain; charset=&quot;us-ascii"
>;
> Hello PJUGsters,
>
> We have an immediate need for a "Java Expert&quot; that has hands on
> experience with Eclipse RCP (Rich Client Platform).
>
> The industry: Aerospace
> The location: Bellevue, WA (Eastgate)
> The duration: Initally through March
> The hours: 8-4:30
>; The pay: Pretty darn good
>
> This is a development role. This position is in need of someone with the
> HIGHEST level of coding skills.
&gt;
> Damon Thomas | Aerospace Program Manager
&gt; CDI Business Solutions
> 4040 Lake Washington Blvd NE #101 Kirkland, WA 98033
> 425.739.2101 office | 206.355.5922 cell | 425.739.7838 fax
> www.cdicorp.com <http://www.cdicorp.com/>
>;
> ______________________________________________________________________
> CONFIDENTIALITY NOTICE:&nbsp; This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain information which is confidential to, and/or privileged in favor of, CDI Corporation or its affiliated companies (CDI) or CDI's customers.  ;Any review, use, reproduction, disclosure or distribution by the recipient is prohibited without prior written approval from an authorized CDI representative.  This notice must appear in any such authorized reproduction, disclosure or distribution. &nbsp;If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message and any attachments. &nbsp;Thank you.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: /pipermail/javamail_pjug.org/attachments/20061109/7164cb7a/attachment-0001.html
>
> ------------------------------
>
> _______________________________________________
> Javamail mailing list
> Javamailpjug.org">Javamailpjug.org
> http://www.pjug.org/mailman/listinfo/javamail_pjug.org
>
>
> End of Javamail Digest, Vol 8, Issue 7
> **************************************
>
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )