gpt4 book ai didi

excel - 如何使用powershell将excel 2007保存为html格式?

转载 作者:行者123 更新时间:2023-12-03 02:14:13 27 4
gpt4 key购买 nike

您好,我尝试使用该代码

$e = New-Object -ComObject "Excel.Application"
$e.Visible = $true
$ew = $e.Workbooks.Open("C:\Users\mich\14_50_33__5_Pt_50_sie_2011.xls")
$ew.SaveAs("C:\Users\mich\Documents\test", "Excel.XlFileFormat.xlHtml")

我做错了什么?

<小时/>

这是我自己的工作代码:

$xlExcelHTML = 44
$Excel = New-Object -ComObject "Excel.Application"
$Excel.Visible = $true
$WorkBook = $Excel.Workbooks.Open("C:\Users\mich\14_50_33__5_Pt_50_sie_2011")
$WorkSheet = $WorkBook.Worksheets.Item(1)
$WorkBook.SaveAs("C:\temp\test8",$xlExcelHTML)
<小时/>

这里是格式扩展代码的链接:http://msdn.microsoft.com/en-us/library/bb241279(office.12).aspx

最佳答案

这对我有用。您需要将 12 个参数传递给 saveAs 方法。用 [type]::Missing 填充每个未指定的参数

$xlHtml = 44
$missing = [type]::Missing
$xl = New-Object -ComObject Excel.Application
$xl.Visible = $true
$wb = $xl.Workbooks.Open('d:\book1.xlsx')
$xl.ActiveWorkbook.SaveAs('d:book1.html',$xlHtml,$missing,$missing,$missing,$missing,$missing,$missing,$missing,$missing,$missing,$missing)
$xl.Quit()

关于excel - 如何使用powershell将excel 2007保存为html格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6972494/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com