• Post Reply Bookmark Topic Watch Topic
  • New Topic

OLE and Java  RSS feed

 
Claude Moore
Ranch Hand
Posts: 924
9
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I'm recently working with a swing app, in which I need to embed and Excel component. After searching for a while, I've found a couple of interesting commercial API that would let me to achieve my goal. Besides that, I've just a question: what would be the best way to approach similar tasks in Java ? With .NET it would be quite simple to work with Microsoft product via OLE / ActiveX ( and that's obvious, you may reply, since with .NET you're on home ground), and I suppose that, because of Java platform indipendency, there will virtually never be a 'native' support for OLE...

Any suggestion ?

Thank you in advance.


 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Claude Moore wrote:Any suggestion ?

As usual, the answer is: it depends. How much interaction does your desktop app have to have with Excel?

The main problem you have is that Excel is proprietary software; and MS are very Victorian in their attitudes to letting anyone play with 'their stuff' unless you pay them lots of money.

There is, however, OpenOffice, which doesn't cost a dime, has its own spreadsheet app (which can import most Excel files), and has full integration with Java (although the API is quite big). You also have things like Apache POI which give you limited support for updating Excel files directly, but you'd have to read their docs to find out what those limits are.

Personally, I'd go with OpenOffice. I dumped all my MS Office software years ago, but it may not be an option for you if you work in a company.

Winston
 
Claude Moore
Ranch Hand
Posts: 924
9
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Winston and thank you for your reply.

My main goal is to embedd a spreadsheet into my Swing application. In fact, with some open source libraries, i've been able to manipulate xls files for many years.
If it were possible to integrate and redistribute only Open Office Calc libraries, it would be a perfect solution. I investigated a bit and what I understood is that it is
not possible to embedd an OO spreadsheet in a swing application; even if it were possible, it would be necessary to have OO suite installed on single pc.
That's not a feasible solution. Most of computers of customers I have to deal with have Microsoft Office installed on, so it would be nice to directly use them, instead installing
OO only as a required component.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Claude Moore wrote:My main goal is to embedd a spreadsheet into my Swing application.

Yes, but there's all sorts of levels of "embedding". If you simply want to be able to run Excel from your GUI, you could probably do it in 5 minutes with Runtime.exec() and maybe a .BAT file, but I suspect you want more than that.

If it were possible to integrate and redistribute only Open Office Calc libraries, it would be a perfect solution. I investigated a bit and what I understood is that it is not possible to embedd an OO spreadsheet in a swing application; even if it were possible, it would be necessary to have OO suite installed on single pc.

That doesn't sound right to me. All you'd have to do is include the OO jars inside your own. The only thing I'm not sure about is if there are any copyleft rules you have to follow, and exactly how much integration there is with Swing. I imagine it'd be pretty good though, because I'm pretty sure that most of OO is actually written in Java.

Providing these files aren't too exotic, you can certainly import an xls into calc, do your stuff, and then write it out in .xls format (although the format may not be bang up to date - proprietary brick wall again).

Most of computers of customers I have to deal with have Microsoft Office installed on, so it would be nice to directly use them, instead installing
OO only as a required component.

See above. I suspect that whether you use OO or POI, you're going to run into some restrictions, so don't reckon on a 100% solution.

Winston

[Edit] PS: There is another fork of OpenOffice out there called LibreOffice, which I think also has quite extensive Java support. Never used it though, so can't advise.
 
Claude Moore
Ranch Hand
Posts: 924
9
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but there's all sorts of levels of "embedding". If you simply want to be able to run Excel from your GUI, you could probably do it in 5 minutes with Runtime.exec() and maybe a .BAT file, but I suspect you want more than that.


Well, of course I mean a real embedding solution, i.e having a spreadsheet inside my own JFrame, just to give an idea.

There is another fork of OpenOffice out there called LibreOffice


Nice to know. I'll give it a try.

Thank you for your help.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Claude Moore wrote:Thank you for your help.

You're welcome.

Winston
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might consider looking at SWT (home page) instead of Swing. I followed the "Examples" link from that page and noticed that there was an "OLEExample" you could look at.
 
Claude Moore
Ranch Hand
Posts: 924
9
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

that's another good suggestion... to be quite honest, I had already a look at SWT examples; at the moment i'm using Swing and it would unpracticable to switch to SWT. I'll verify how to integrate Swing and SWT, I'm quite sure that it's possible without much pain (at least untill SWT usage remains limited at very few point in the overall code).

Just to summarize this topic: I think that both SWT or third part library usage and trying to embedding a open source project like LibreOffice would be feasible solutions. Using OLE would tie up my application only to Windows SO, and even in Windows enviroment I would have Office as prerequisite for certain operations. Embedding an open source would be more difficult, more expensive (in terms of space required and in distributing my application) but would let me just to assume nothing about software installed on each computer; moreover, I'd rely on working with a specific version of a spreadsheet software of my own choice (without worrying about which version may be installed).

Thank you, all, for your support and time.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!