How to Convert the text format value in Excel Cells into a Number Format

Screenshot 2021-12-08 115603
want to convert left aligned value into right aligned value

Hi,

If you change format to number also it will not remove that error on convert to number in the excel. use the invoke code activity with below vb code to change the format.

Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim cell As Microsoft.Office.Interop.Excel.Range

Try
excel = New Microsoft.Office.Interop.Excel.ApplicationClass
wb = excel.Workbooks.Open(“Your excel file path”)
excel.Visible=True

ws=CType(wb.Sheets(“Your Sheet Name”),Microsoft.Office.Interop.Excel.Worksheet)
ws.Activate

For Each cell In ws.Range(“E2:E10”).Cells
cell.Value = cell.Value
Next

Catch es As Exception
'System.Windows.MessageBox.Show(es.Message)
End Try

wb.Save
wb.close
excel.Quit
wb=Nothing
ws=Nothing
excel=Nothing
GC.Collect()

Hi @Gopikrishna_S

Use this syntax Currentrow(“DEBITS”).ToString("#,##0.00")

which will be able to get your desired output

Thanks,

is this need any packages to be installed before using invoke code

yeah install microsoft.office.interop.excel pakcage. For me also i have faced the same convert to number warning error for all the cells. i have resolved with the above method. thanks.


But Cant able to find it

Hi,

you are checking in project dependencies. you have to check in all packages. thanks.

Same issue


Same issue again

not sure may be we have to check the settings for the activities feed. lets leave it just try to add the name space in the project. like below and try that invoke code activity.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.