Skip to content

Instantly share code, notes, and snippets.

@hclpandv
Created August 25, 2017 11:20
Show Gist options
  • Select an option

  • Save hclpandv/a656ad9f5e32b937121e2a453240a46d to your computer and use it in GitHub Desktop.

Select an option

Save hclpandv/a656ad9f5e32b937121e2a453240a46d to your computer and use it in GitHub Desktop.
PowerShell Function Save-XlsAsCSV
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