Hi all,
i I have a small issue, i open an excel through Powershell and convert it ( bettere say save it as) a CSV file.
The issue is that i would like to have the Dates inside the Excel converted to the Regional Settings on the machine.
I've seen that if a place a custom value in one of the cell, for example yyyy-mm-dd, in the CSV that is generated i find a value like 2018-02-22.
If there a way to force it to convert that value to the Regional Setting.
So if [System.Threading.Thread]::CurrentThread.CurrentCulture is set to "it-IT" all dates should be "dd/mm/yyyy"
The code so far is fairly straightforward
#Get ID to Close Excel later $priorExcelProcesses = Get-Process -name "*Excel*" | % { $_.Id } $excelApp = New-Object -ComObject Excel.Application $postExcelProcesses = Get-Process -name "*Excel*" | $excelApp.DisplayAlerts = $false $workbook = $excelApp.Workbooks.Open($ExcelFiles) #Position to the First Sheet of the Excel $Worksheet = $Workbook.WorkSheets.item(1) $worksheet.activate() #Save the Excel as a CSV file $csvFilePath = $ExcelFiles -replace "\.xls$", ".csv" -replace "\.xlsx$", ".csv" $workbook.SaveAs($csvFilePath, [Microsoft.Office.Interop.Excel.XlFileFormat]::xlCSV) $workbook.Close() # Release Excel Com Object resource $excelApp.Workbooks.Close() Start-Sleep 5 $excelApp.Quit()