Skip to content

Instantly share code, notes, and snippets.

@Jonathan727
Created August 10, 2023 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jonathan727/9abf7ba290b32f74ae21e8fa55c631eb to your computer and use it in GitHub Desktop.
Save Jonathan727/9abf7ba290b32f74ae21e8fa55c631eb to your computer and use it in GitHub Desktop.
Powershell command to convert all xlsx files in a directory to csv files.
$excelApp = New-Object -ComObject Excel.Application;`
$excelApp.DisplayAlerts = $false;`
Get-ChildItem -File -Filter '*.xlsx' | ForEach-Object { `
$workbook = $excelApp.Workbooks.Open($_.FullName);`
$csvFilePath = $_.FullName -replace "\.xlsx$", ".xlsx.csv";`
<# If Microsoft.Office.Interop.Excel.XlFileFormat, try running from Visual Studio Developer Powershell #>`
$workbook.SaveAs($csvFilePath, [Microsoft.Office.Interop.Excel.XlFileFormat]::xlCSV);`
$workbook.Close();`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment