我发现awesome scrip t工作正常,但在转换发生后我无法保留单元格的前导零。
使用此脚本
if WScript.Arguments.Count < 2 Then
WScript.Echo "Error! Please specify the source path and the destination. Usage: XlsToCsv SourcePath.xls Destination.csv"
Wscript.Quit
End If
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))
oBook.SaveAs WScript.Arguments.Item(1), 6
oBook.Close False
oExcel.Quit
WScript.Echo "Done"
转化前(Xlsx文件)
转换后(CSV文件)
更新
如果我尝试添加此内容:
oBook.Application.Columns("A:ZZ").NumberFormat = "@"
到我的脚本如下,它对将数字单元格格式化为文本没有任何影响
if WScript.Arguments.Count < 2 Then
WScript.Echo "Error! Please specify the source path and the destination. Usage: XlsToCsv SourcePath.xls Destination.csv"
Wscript.Quit
End If
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))
oBook.Application.Columns("A:ZZ").NumberFormat = "@"
oBook.SaveAs WScript.Arguments.Item(1), 6
oBook.Close False
oExcel.Quit
WScript.Echo "Done"
来源:https://msdn.microsoft.com/en-us/library/office/ff195212.aspx