tags:

views:

1004

answers:

3

Hi, I just want to know if there could be any way by which we can read a value from an .xls file using a .bat file. For eg:If i have an .xls named test.xls which is having two columns namely 'EID' and then 'mail ID'.Now when we give the input to the .xls the EID name.it should extract the mail id which corresponds to the EID and echo the result out.

**EID**                  **MailID**
E22222                    [email protected]

E33333                    [email protected]

...
...

So by the above table,when i give the input to the xls file using my .bat file as E22222,it should read the corresponding mail ID as [email protected] and it should echo the value.

So i hope i am able to present my doubt.Please get back to me for more clarifications.

Thanks and regards Maddy

+2  A: 

There is no facility to do this directly with traditional .bat files. However, you might investigate PowerShell, which is designed to be able to do this sort of thing. PowerShell integrates well with existing Windows applications (such as Excel) and may provide the tools you need to do this easily.

A quick search turned up this example of reading Excel files from PowerShell.

Greg Hewgill
Thanks a lot Greg.But just confused as to which to use.Because i need this mail ID so that i can add to my cruiseControl.NEt config files mail ID section
A: 

This will be hard (very close to impossible) in BAT, especially when using the original XLS file, but even after an export to CSV it will be much easier to use a script/programming language (Perl, C, whatever) to do this.

schnaader
A: 

You can't do this directly from a batch file. Furthermore, to manipulate use Excel files in scripting you need Excel to be installed.

What you can do is wrap the Excel-specific stuff in a VBScript and call that from your batch.

Joey