且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从Powershell打开Excel工作簿以实现自动化

更新时间:2022-12-01 21:24:53

您需要将其作为ComObject打开.

You need to open it as a ComObject.

$Excel = New-Object -ComObject Excel.Application
$Workbook = $Excel.Workbooks.Open($FilePath)

在该示例中,您需要将$FilePath定义为要打开的Excel文件的完整路径.

In that example you would have needed to define $FilePath as the full path to the Excel file that you are trying to open.