2022-02-18

Using Powershell to convert text to number in Excel

I have an excel file that has three columns that are set to Number. However, when I open the file I have the this :

convert to number

I found a helpful link here: stackoverflow link

I have tried this method but I am getting the following error. Is there something I am doing wrong:

$wb = 'C:\Users\user1\Documents\Working Folder\239\239_uploadFile.xlsx'
$excel = new-object -ComObject excel.application
$excel.visible = $false
$excel.DisplayAlerts = $false
$wb = $excel.workbooks.open($wb)
$ws1 = $wb.worksheets.item(3)

$ws1.columns.item(1).numberformat = 0
$ws1.Columns.item(14).Value = $ws1.Columns.item(14).Value



$wb.Save()
$wb.close()
$excel.Quit()
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($excel)
Remove-Variable excel`

[Powershell error



from Recent Questions - Stack Overflow https://ift.tt/jl2hk3P
https://ift.tt/u73j1fP

No comments:

Post a Comment