在powershell中按列值筛选所选范围

时间:2016-10-05 21:36:23

标签: excel powershell powershell-v2.0

我使用PowerShell成功地将一个excel范围复制到另一个excel,如下所示:

$Excel = New-Object -ComObject excel.application 
$Excel.visible = $false 
$Workbook = $excel.Workbooks.open($pathSource) 
$WorkbookDestination = $excel.Workbooks.open($pathDestination) 
$Worksheet = $Workbook.WorkSheets.item("Page 1") 
$Worksheet.activate()  
$range = $WorkSheet.Range($columnName).EntireColumn


$range.Copy() | out-null 
$WorksheetDestination = $WorkbookDestination.Worksheets.item("Destination") 
$Range = $WorksheetDestination.Range("A1") 
$WorksheetDestination.Paste($range)  
$WorkbookDestination.Save()  
$Excel.Quit() 
Remove-Variable -Name excel 

我希望在复制到另一个excel之前,从所选范围中过滤信息(即第18列等于“某些值”)。

PowerShell v2。

0 个答案:

没有答案