2
votes

Is there a way I can write a batch script (windows .bat file) that will take two excel files (xls, xlsx, csv) and merge them into one excel file? Both the files will have common columns, and have one sheet each. I need the merged excel to have one sheet with the contents of both the files. Also, the two files can have different formats, like one being xls and other being csv.

Any help on this?

Thanks.

1
Default cmd line utility won't help on this. Not sure if there is any external program that does this with command line.nhahtdh

1 Answers

0
votes

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 join two data from Excel file and CSV file you can use the following command:

> node alacon "SELECT * INTO XLSX("main.xls",{headers:true}) 
               FROM XLSX('data1.xlsx', {headers:true}) data1
               JOIN CSV('data2.csv', {headers:true}) data2 ON data1.id = data2.id"

This is one very long line. In this example all files have data in "Sheet1" sheets.