I am new to ant and I am looking for a way to open an excel file via an ant command. Right now, my program runs in a way that I specify an Excel file I want to open on my local machine. However, I want it so that the user, when typing the ant command, can specify the location/name of the Excel file as a command line argument and open it up that way. I have looked around at different ant commands like ant exec but to my knowledge, it seems to only execute executables if you specify the location. I was looking at Using Ant, how do I open a file in a browser? for hints but this seems to run an executable. Any ideas how to do so? If so, that would be great!
Asked
Active
Viewed 325 times
-1
-
Why do you want to use ant for that? – Thorbjørn Ravn Andersen Jul 21 '14 at 18:16
-
@ThorbjørnRavnAndersen As an end goal, I want to package up my whole project into a jar and then create a bash script executable so that if someone non-technical uses this program, if I tell them the correct location/name of the excel file, they can double click on the executable and it will simply run the jar for them without having them learn how to run command line arguments and such. – user1567909 Jul 21 '14 at 18:21
-
Drop ant launching and just figure out how you invoke "start.exe" from your own java code – Thorbjørn Ravn Andersen Jul 21 '14 at 19:17
-
See also: http://stackoverflow.com/questions/22727192/using-apache-ant-commands-to-store-value-to-excel-cell/22729674#22729674 – Mark O'Connor Jul 21 '14 at 23:20
1 Answers
0
the link you've included in your question seems sufficient.
for opening the Excel
file, this should work:
<exec executable="-path-of-excel-exe-" spawn="true">
<arg value="${user_file}"/>
</exec>
-path-of-excel-exe-
is the path to EXCEL.EXE
on your sys. for eg, on my system,
"C:\Program Files\Microsoft Office\Office14\EXCEL.EXE"
now, as for accepting the file location, i.e. ${user_file}
in our case, as a command-line argument, this should work:
ant -Duser_file="file location"
-D<property_name>=<property_value>
use value for given property, see HERE. so, the "property_name"
specified here can be used in you .xml
file and the corresponding "property_value"
will be substituted.

sunbabaphu
- 1,473
- 1
- 10
- 15