Convert XLS to CSV on command line

后端 未结 15 2224
臣服心动
臣服心动 2020-11-22 12:11

How could I convert an XLS file to a CSV file on the windows command line.

The machine has Microsoft Office 2000 installed. I\'m open to installing OpenOffice if it\

15条回答
  •  长情又很酷
    2020-11-22 12:42

    :: For UTF-8 works for Microsoft Office 2016 and higher!

    Try this code:

    if WScript.Arguments.Count < 2 Then
        WScript.Echo "Please specify the source and the destination files. Usage: ExcelToCsv  "
        Wscript.Quit
    End If
    
    csv_format = 62
    
    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
    

提交回复
热议问题