I want to open the CSV file using powershell Excel.Application. my code is like this:
$csv = "csv name"
$xlsx = "output excel name"
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $false
$wb = $excel.Workbook.Open($csv)
$wb.SaveAs($xlsx,51)
$excel.Quit()
But Turns out that the data in the csv "004" will loaded as 4
Anyone can think of a way to do this?
Noted that there are many special case in my csv:
- there are data like "004", "01234678" in the csv and I would like to import all of them as text.
- there are comma within the data like "FlatA, 7/F"
- there are newline character within the data like "abcdef def ghi" you can also give your own solution that can load the csv to excel using powershell which can fulfill all the above cases.
Thanks a lot. You will save my life if you able to do this.