============================================
基础依赖:安装office软件
============================================
直接保存为xls_2_csv_ex.vbs.
运行方式:xls_2_csv_ex.vbs aaa.xls 会自动生成 aaa.xls.csv (拖拽aaa.xls文件到xls_2_csv_ex.vbs即可)
if WScript.Arguments.Count <> 1 Then
WScript.Echo "Error! Please specify the source path and the destination. Usage: xls_2_csv xls_file_name.xls"
Wscript.Quit
End If
date_fmt = "yyyy/mm/dd"
date_columns = Array(1)
Set oExcel = CreateObject("Excel.Application")
oExcel.DisplayAlerts = False
oExcel.Visible = False
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))
For Each oSheet In oBook.Worksheets
For Each column in date_columns
oSheet.Columns(column).NumberFormat = date_fmt
Next
Next
oBook.SaveAs WScript.Arguments.Item(0)&".csv",6,False
oBook.Close True
oExcel.Quit
WScript.Echo "Done"
直接保存为xls_2_csv.vbs.
运行方式:xls_2_csv.vbs aaa.xls 会自动生成 aaa.xls.csv (拖拽aaa.xls文件到xls_2_csv_ex.vbs即可)
if WScript.Arguments.Count <> 1 Then
WScript.Echo "Error! Please specify the source path and the destination. Usage: xls_2_csv xls_file_name.xls"
Wscript.Quit
End If
Set oExcel = CreateObject("Excel.Application")
oExcel.DisplayAlerts = False
oExcel.Visible = False
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))
oBook.SaveAs WScript.Arguments.Item(0)&".csv",6,False
oBook.Close True
oExcel.Quit
WScript.Echo "Done"