使用 PowerShell 将 Excel 文件另存为 XML

编程入门 行业动态 更新时间:2024-10-28 12:26:50
本文介绍了使用 PowerShell 将 Excel 文件另存为 XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我目前正在用 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-24 06:48:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1058629.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:另存为   文件   PowerShell   Excel   XML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!