为什么这会在HBHS1.csv文件的末尾创建额外的行?它正在创建第四行,其中包含某种特殊字符。在记事本++中,它显示为: 空行,但生成的* .csv文件在第四行中显示类似于[]的符号。
FOR /f "delims=" %%i IN ('DIR *.xls* /b') DO to-csv.vbs "%%i" "%%i.csv"
More +1 HBHS1.xlsx.csv > HBHS1.csv
to-csv.vbs
'source: http://stackoverflow.com/a/10835568/715608
if WScript.Arguments.Count < 2 Then
WScript.Echo "Please specify the source and the destination files. Usage: ExcelToCsv <xls/xlsx source file> <csv destination file>"
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