Taken from my old blog site “Vipinvasudevan.blogspot.com”
Below script help you to convert any excel files in to csv format
#————–Script Start—————————–
#Convert Excel file to CSV
$xlCSV=6
$Excelfilename = “C:\Temp\file.xlsx”
$CSVfilename = “C:\Temp\file.csv”
$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}#————–Script End—————————–
In case if you have multiple files of .xlsx in same location, and want to convert all in to CSV. Chang the script like
#————–Script Start—————————–
#Convert Excel file to CSV
Path = get-childitem -path “<Your path>”
$xlCSV=6
foreach ($file in $path) {
$Excelfilename = $file.fullname
$CSVfilename = “” + $file.Basename+ “CSV”$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}
}#————–Script End—————————–