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

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

问题描述

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

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

机器安装了 Microsoft Office 2000.如果无法使用 Microsoft Office,我愿意安装 OpenOffice.

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天全站免登陆