我使用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。