Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

searching multiple xls docs with powershell

$
0
0

Hi,

I have a folder structure with many excel docs that I am looking to search and return the matching row data along
with the file location and sheet information. I have the basics now, but cant seem to be able to get the search
part correct. Can someone help with the best method to search and return results from multiple worksheets ?


$search = "powershell" $path = "e:\powershell\excel_test\" $excelSheets = Get-Childitem -Path $path -Include *.xls,*.xlsx -Recurse $excel = New-Object -comobject Excel.Application $excel.visible = $false foreach($excelSheet in $excelSheets) { $workbook = $excel.Workbooks.Open($excelSheet,2,$true) $worksheets = $workbook.sheets $workbook.name + " has " + $worksheets.count + " worksheets to check" $workbook.close() } #end foreach $excel.quit() $excel = $null [gc]::collect() [gc]::WaitForPendingFinalizers()



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>