Convert *.xls or *.xlsx file to pipe separated .csv file using command line
<p>I have an .xlsx file like this:</p>

<h2>sample.xlsx:</h2>

<pre><code>Heading     C1      C2,01,02    C3    C4
R1          1       4           7     10
R2          2       5           8     11,1
R3          3       6           9,0   12
</code></pre>

<p>I want to convert sample.xlsx file into Output.csv file [pipe separated].</p>

<p>Please note that I don't want any double quotes "C2,01,02".</p>

<h2>Output.csv:</h2>

<pre><code>Heading|C1|C2,01,02|C3|C4
R1|1|4|7|10
R2|2|5|8|11,1
R3|3|6|9,0|12
</code></pre>

<p><strong>I know how to produce Output.csv using manual steps like this:</strong></p>

<p>Goto control panel -> Region and Language -> Additional Settings -> update list separator field with pipe "|".</p>

<p>Open sample.xlsx -> save as -> from the drop down select save as type CSV(Comma delimited)(*.csv). </p>

<p>But I don't want to do this manually. I want to achieve the same Output using command line. For this, I have taken reference from this post:
<a href="https://stackoverflow.com/questions/1858195/convert-xls-to-csv-on-command-line">Convert XLS to CSV on command line</a></p>

<p><strong>Code is:</strong> </p>

<p>This csv works perfectly but the only problem is that it produces comma separated csv instead of pipe separated.</p>

<blockquote>
<pre><code>if WScript.Arguments.Count &lt; 2 Then
    WScript.Echo "Please specify the source and the destination files. Usage: ExcelToCsv &lt;xls/xlsx source file&gt; &lt;csv destination file&gt;"
    Wscript.Quit
End If
csv_format = 6
Set objFSO = CreateObject("Scripting.FileSystemObject")
src_file = objFSO.GetAbsolutePathName(Wscript.Arguments.Item(0))
dest_file = objFSO.GetAbsolutePathName(WScript.Arguments.Item(1))
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(src_file)
oBook.SaveAs dest_file, csv_format
oBook.Close False
oExcel.Quit
</code></pre>
</blockquote>

<p><strong>To run the above code:</strong></p>

<p>XlsToCsv.vbs [sourcexlsFile].xls [Output].csv</p>

<p>I tried changing value of csv_format = 6 with many other values like 1,2,3...and so on. but it's not giving pipe separated csv.</p>

<p>Please help.</p>

<p>Thanks in advance.</p>