#--------------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-----------------------------
5 comments:
Use for first two lines:
#Convert Excel file to CSV
$xlCSV=6
Sorry for the later response! But yes we can..
$path = get-childitem -path "Your path"
foreach ($file in $path) {
$Excelfilename = $file.fullname
$CSVfilename = "" + $file.Basename+ "CSV"
#Convert Excel file to CSV $xlCSV=6
$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}
Oops!!! *late reponse
Vipin, I am trying to use your script to convert excel to csv files. I have creditcard numbers and 16 digit is rounding off. Is there a way to work around that please?
Thanks in advance.
I know Excel has a built in feature to identify credit card numbers :( but there's a work-around out there.
Post a Comment