Created
August 25, 2017 11:20
-
-
Save hclpandv/a656ad9f5e32b937121e2a453240a46d to your computer and use it in GitHub Desktop.
PowerShell Function Save-XlsAsCSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Save-XlsAsCSV ($excelFile, $csvFile) | |
| { | |
| $E = New-Object -ComObject Excel.Application | |
| $E.Visible = $false | |
| $E.DisplayAlerts = $false | |
| $wb = $E.Workbooks.Open($excelFile) | |
| foreach ($ws in $wb.Worksheets) | |
| { | |
| $n = $excelFile + "_" + $ws.Name | |
| $ws.SaveAs($csvFile, 6) | |
| } | |
| $E.Quit() | |
| } | |
| Save-XlsAsCSV -excelFile "C:\Temp\MyExcel.xlsx" -csvFile "C:\Temp\MyExcel.csv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment