如何通过批量跳过某些行将 excel 文件转换为 CSV?
How can I convert an excel file into CSV with batch skipping some rows?
我被要求寻找一个将 Excel 文件转换为 CSV 文件的程序,但我对 .bat 一无所知。我看到有人用一些命令这样做,我想知道我是否可以这样做,但 重要:跳过文件的前五行。
如果你能给我任何帮助,我将不胜感激。
一个非常简单的方法是创建一个 vbs 脚本。将以下内容粘贴到记事本中并另存为 XlsToCsv.vbs
。确保提供 sourcexlsFile
和 destinationcsvfile
的完整路径
使用:XlsToCsv.vbs [sourcexlsFile].xls [destinationcsvfile].csv
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.Sheets(1).Range("1:5").EntireRow.Delete 'this removes the first five rows everytime
oBook.SaveAs WScript.Arguments.Item(1), 6
oBook.Close False
oExcel.Quit
WScript.Echo "Done"
我被要求寻找一个将 Excel 文件转换为 CSV 文件的程序,但我对 .bat 一无所知。我看到有人用一些命令这样做,我想知道我是否可以这样做,但 重要:跳过文件的前五行。
如果你能给我任何帮助,我将不胜感激。
一个非常简单的方法是创建一个 vbs 脚本。将以下内容粘贴到记事本中并另存为 XlsToCsv.vbs
。确保提供 sourcexlsFile
和 destinationcsvfile
使用:XlsToCsv.vbs [sourcexlsFile].xls [destinationcsvfile].csv
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.Sheets(1).Range("1:5").EntireRow.Delete 'this removes the first five rows everytime
oBook.SaveAs WScript.Arguments.Item(1), 6
oBook.Close False
oExcel.Quit
WScript.Echo "Done"