I have a script which converts from xls to csv. It is very simple and just opens the xls with an Excel Object and saves it as csv:
cls Remove-Item *.csv $stringBuilder = New-Object System.Text.StringBuilder $objExcel = New-Object -ComObject Excel.Application $objExcel.Visible = $false $Tab = [char]9 $Pestana = 2
# Lee todos los excel de esta carpet $ListadoExcel = Get-ChildItem -filter "*.xlsx" foreach ($Linea in $ListadoExcel) {
$Archivo = $Linea.FullName
$ArchivoCorto = $Archivo.Replace('.xlsx','')
"Procesando: "+$Archivo
$WorkBook = $objExcel.Workbooks.Open($Archivo,$null,$True) #Solo lectura
#Leemos la tercera pestaña
$WorkSheet = $WorkBook.sheets.item($Pestana)
$WorkSheet.SaveAs($ArchivoCorto+".csv", 23)
#"Filas leidas: "+$Filas
#$range = $WorkSheet.UsedRange
#$WorkSheet.Range('B5').Text
#$stream.WriteLine($WorkSheet.UsedRange.Cells.Item.Text)
$WorkBook.Close($False) #Sin guardar }
$objExcel.Quit()
The weird thing is that the result csv is delimited with ,
when I want to be delimited with ;
.
If I do (Get-Culture).TextInfo.ListSeparator
I get ;
.
I also have the same delimiter in Regional and language settings in Control Panel.
If I take the same Excel and do a save as manually the resultant csv is delimited with ";".