Created
May 11, 2023 20:37
-
-
Save kjeske/28cf9c3bf1ec6bc2538553a128c59051 to your computer and use it in GitHub Desktop.
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
| param ([string]$excelFileName) | |
| Set-ExecutionPolicy Bypass -Scope Process | |
| [System.Threading.Thread]::CurrentThread.CurrentCulture = New-Object "System.Globalization.CultureInfo" "en-US" | |
| Function ExportWSToCSV ($excelPath, $csvFileName) | |
| { | |
| $excelFile = Get-Item $excelPath | |
| $excelLocation = $excelFile.DirectoryName | |
| $E = New-Object -ComObject Excel.Application | |
| $E.Visible = $false | |
| $E.DisplayAlerts = $false | |
| $wb = $E.Workbooks.Open($excelPath) | |
| $ws = $wb.Worksheets[1] | |
| $path = Join-Path -Path $excelLocation -ChildPath ($csvFileName + "_" + $ws.Name + ".csv") | |
| $ws.SaveAs($path, 6) | |
| $E.Quit() | |
| } | |
| ExportWSToCSV -excelPath $excelFileName -csvFileName "out1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment