How to change Excel format of a cell to number

Hi all,

Currently I am writing a data table to an excel file that has an “amount” column with number values. When the program finishes and I open the excel the format of the cell is a “Text” format. I wanna know is there any way to change the formatting to “Number”? Any help is appreciated thanks!

Invoke this below vb.net code in uipath, @kahoyim
and edit as per your need and download Excel Interop package,

Dim xlsApp As New Excel.Application
xlsApp.Visible = True
Dim xlsWorkbook As Excel.Workbook = xlsApp.Workbooks.Open(“C:\Users\v-padee\Desktop\demo.xlsx”)
Dim constant As Excel.XlCellType
constant = Excel.XlCellType.xlCellTypeConstants
With xlsWorkbook.Worksheets(1).Range(“A:A”).SpecialCells(constant, 2)
.NumberFormat = “General”
.Value = .Value
End With
and for more information check this below link,
https://social.msdn.microsoft.com/Forums/vstudio/en-US/a3abc620-2a16-46fc-8ab6-6d1d825601da/vbnet-excel-interop-quotconvert-to-numberquot-column?forum=exceldev

1 Like