Hi. I'm completing a program which to make a long story short retrieves data from an Oracle database and outputs this to a flat file(*.csv) which in turn will be used in Excel 97 for reports. I was wondering what the best way of going about opening this file up for viewing in Excel through my Java program would be(i.e. clicking "File") instead of finding the file manually outside of the Java program and double clicking it. Any thoughts?
You might be able to run excel with a command line argument of the csv file.
Make sure that the csv file is in a format that excel can understand. The format for excel csv is a bit different than most. I have written libraries to help out with csv files. You can get them here: http://ostermiller.org/utils/CSVLexer.html
Hi Steve. Thanks for the quick response. I just tried your idea and it works great! I was wondering though(now...), everybody that's gonna use this program has the same image(I work at a college and this assumption is quite accurate), but, what if per chance they don't have 'excel.exe' where 99% of people do... is there a way to find it? I'll have no problem creating the dynamic filenames(cause they'll be different all the time) but what about the .exe? This question is just out of curiosity...
If you tell the command shell to "start" the .csv file, it will use whatever application is associated with .csv files; if they don't have Excel but they do have Works or something else then that's what would be used. This is one of the cleaner ways to do this as it works with any application that knows about csv files and not just Excel. On WinNT, the code would be something likeOn Win9*/Me, the command interpreter is command.com. The COMSPEC environment variable will tell you which of the two you need to use. - Peter [ March 19, 2002: Message edited by: Peter den Haan ]
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop