r/PowerShell • u/Ultimate_Harrier • 17d ago
Question Importing specific rows from a .xslx-file to a .csv file
This is probably the most simple thing ever so apologies.
So I have an Excel worksheet and I want to import the data from specific rows, if column D in those rows has a certain value in it.
So using ImportExcel what I have is:
import-excel -path "filelocation" -WorksheetName "Worksheetname" | export-csv -path "exportlocation" -NoTypeInformation
What would be the missing bit to get the specific info I'm looking for? Again, I'm sorry for asking for what is probably a very simple solution.
13
Upvotes
8
u/jungleboydotca 17d ago
Filter in the middle with
Where-Object:...if your sheets have headers, use the name of the header in the column specification.
0
u/AGsec 17d ago edited 17d ago
You can use a loop that goes through each row, uses select-string to find the data, and if there is a match, then grab all of the data from that row and place it into an array for future export.
If you are going to downvote, please explain why. This is a place to learn. If my answer isn't good enough, technically or content wise, explain so I can do better.