Hello, If I want to invoke an executable from a java program I use the following. Runtime.getRuntime().exec("notepad"); This works. HOW TO INVOKE "EXCEL" ? Thank you in advance Garandi
Maulin Vasavada
Ranch Hand
Joined: Nov 04, 2001
Posts: 1865
posted
0
hi v, notepad is a name of the executable for the Notepad and similarly you should be able to use the executable for the excel that is 'excel.exe'. u might have to give the full path to the exe of the excel on ur machine... try it..i don't have ms excel right now on my machine so i can't comment more.. regards maulin
you would have to give the path of excel.exe for it to get working...as notepad.exe is in \windows folder...but same is not with excel.exe so put Runtime.getRuntime().exec("<path>/excel.exe"); this shud work MB
Q1:-But how to find the path for excel.exe on a given arbitrary machine? Q2:- How to open an excel file, eg TestFile.xls Thank you Jawad [ April 01, 2003: Message edited by: Garandi Garandi ]
Maulin Vasavada
Ranch Hand
Joined: Nov 04, 2001
Posts: 1865
posted
0
hi Garandi, here is the code i tried on Win2k. on systems that has "command" instead of "cmd" you might face problem.
it runs for me... hope this helps. regards maulin
Garandi Garandi
Ranch Hand
Joined: Jan 07, 2003
Posts: 192
posted
0
Dear Maulin, It works, thank you very much. Garandi
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
In Win2k puts "start" is not necessary, it�s already to find alone the path. I am brazilian, sorry for my english, I am still learning the english language.
Garandi Garandi
Ranch Hand
Joined: Jan 07, 2003
Posts: 192
posted
0
In my code I write to an excel file and then try to close the output stream, after that invoke
But the problem is that some times it does not invoke the excel file. Q1:- How to make sure it invokes the excel file always. Thank you in advance Garandi
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
posted
0
You can also exec RunDLL32 to launch a file. This seems to be exactly like double-clicking a file in Windows Explorer. The benefit is that you don't have to know the path to the Excel executable. Here's an example you'll find thousands of places on the web for launching a URL into IE. The file can be an Internet URL like this one, or a local file. What they don't all say is that you can launch any file with an association this way.
Copy the part in quotes and type it into a dos box for fun.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi