Created
November 6, 2014 18:29
-
-
Save kavyasukumar/149c59669430dc7f5bf7 to your computer and use it in GitHub Desktop.
Powershell Excel-to-csv
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( | |
$inputPath, | |
$outputPath | |
) | |
$xlCSV=6 | |
$inputPath = (Resolve-path $inputPath).Path | |
$outputpath = (Resolve-path $outputpath).Path | |
get-childitem $inputPath -File | foreach { | |
write-host "processing $_ " | |
$Excelfilename = $_.fullname | |
if(!$outputPath) | |
{ | |
$outputPath = $_.DirectoryName | |
} | |
$CSVfilename =join-path $outputpath $_.BaseName | |
$CSVfilename+=".csv"; | |
#open excel and save | |
$Excel = New-Object -comobject Excel.Application | |
$Excel.Visible = $False | |
$Excel.displayalerts=$False | |
$Workbook = $Excel.Workbooks.Open($ExcelFileName) | |
$Workbook.SaveAs($CSVfilename,$xlCSV) | |
$Excel.Quit() | |
If(ps excel){ | |
kill -name excel | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment