Function ExcelToCsv ($File) {
$Excel = New-Object -ComObject Excel.Application
$wb = $Excel.Workbooks.Open($File)
$x = $File | Select-Object Directory, BaseName
$n = [System.IO.Path]::Combine($x.Directory, (($x.BaseName, 'csv') -join "."))
foreach ($ws in $wb.Worksheets) {
$ws.SaveAs($n, 6)
}
$Excel.Quit()
}
Get-ChildItem C:\Junk\*.xlsx |
ForEach-Object{
ExcelToCsv -File $_
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter