在命令行上将XLS转换为CSV [英] Convert XLS to CSV on command line

查看:953
本文介绍了在命令行上将XLS转换为CSV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Windows命令行上将XLS文件转换为CSV文件。

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

本机安装了Microsoft Office 2000。

The machine has Microsoft Office 2000 installed. I'm open to installing OpenOffice if it's not possible using Microsoft Office.

推荐答案

打开记事本,创建一个名为XlsToCsv.vbs的文件并粘贴到:

Open Notepad, create a file called XlsToCsv.vbs and paste this in:

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"

然后从命令行转到您保存.vbs文件的文件夹并运行:

Then from a command line, go to the folder you saved the .vbs file in and run:

XlsToCsv.vbs [sourcexlsFile].xls [destinationcsvfile].csv

这需要Excel安装在您所在的机器上。

This requires Excel to be installed on the machine you are on though.

这篇关于在命令行上将XLS转换为CSV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆