使用 PowerShell 将 Excel 文件另存为 XML [英] Saving Excel File as XML with PowerShell

查看:49
本文介绍了使用 PowerShell 将 Excel 文件另存为 XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在用 powershell 编写一个脚本,该脚本通过文件树递归搜索 XLS 文件.我想将所有文件保存到 xml 中,以便能够阅读它们并根据需要更改数据.

I'm currently writing a script in powershell that searches for XLS files recursivly through a file tree. I'd like to save all the files to xml to be able to read through them and change data as needed.

无论如何可以使用 Powershell 将 Excel 文件保存为 XML 吗?

Is there anyway to save Excel files as XML with Powershell ?

感谢您的帮助!

---- 更新----

---- Update ----

我在此处找到了一个脚本,它基本上创建了一个excel文件并将其保存为xml.

I found a script here that basically creates an excel file and save it as an xml.

使用相同的原理,我做了以下操作,基本上是打开一个文件并将其保存到 xml:

Using the same principle i did the following, which basically open a file and save it to xml:

$xlXMLSpreadsheet = 46

$Excel = New-Object -Com Excel.Application

$WorkBook = $Excel.Workbooks.Open("c:\Test.xlsx")

$WorkBook.SaveAs("c:\Test.xml", $xlXMLSpreadsheet)

$Excel.Quit()

而且效果很好.但我不知道第二个 saveas() 参数.

And it works really well. But i wasnt aware of the second saveas() parameter.

推荐答案

我找到了一个脚本 here 基本上转换创建一个excel文件并将其保存为xml.

I found a script here that basically converts create an excel file and save it as an xml.

使用相同的原理,我做了以下操作,基本上是打开一个文件并将其保存到 xml:

Using the same principle i did the following, which basically open a file and save it to xml:

$xlXMLSpreadsheet = 46

$Excel = New-Object -Com Excel.Application

$WorkBook = $Excel.Workbooks.Open("c:\Test.xlsx")

$WorkBook.SaveAs("c:\Test.xml", $xlXMLSpreadsheet)

$Excel.Quit()

而且效果很好.但我不知道第二个 saveas() 参数.

And it works really well. But i wasnt aware of the second saveas() parameter.

这篇关于使用 PowerShell 将 Excel 文件另存为 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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