Read a value from a .xls file using .bat files

前端 未结 4 1344
礼貌的吻别
礼貌的吻别 2021-01-25 05:23

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 colu

相关标签:
4条回答
  • 2021-01-25 06:06

    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.

    0 讨论(0)
  • 2021-01-25 06:17

    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.

    0 讨论(0)
  • 2021-01-25 06:22

    You can do it with Alacon - command-line utility for Alasql database.

    It works with Node.js, so you need to install Node.js and then Alasql package:

    To take data from Excel file you can use the following command:

    > node alacon "SELECT VALUE [mail ID] FROM XLS('mydata.xls', {headers:true}) 
                       WHERE EID = ?" "E2222"
    

    Fist parameter is a SQL-expresion, which read data from XLSX file with header and search data for second parameter value: "E22222". The command returns mail ID value.

    0 讨论(0)
  • 2021-01-25 06:24

    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.

    0 讨论(0)
提交回复
热议问题