Excel 单元格格式和四舍五入 VB.NET

Excel cells formatting and round off VB.NET

我怎样才能使这个值

167,155.30 变成 167.16 13,839.15 变成 13.84

我的代码:

xlWs.Cells(dgvRow.Index + 5, dgvColumn.Index + 4).NumberFormat = "#,###.00"

不是 似乎是格式问题,但四舍五入

从单元格中读取一个数字后,将其除以 1000 并显示为 ToString("F2")

Dim num As Double = Convert.ToDouble("167,155.30") 'change this to Excel cell data
Dim displayNum As String = (num/1000).ToString("F2")
'note the /1000

那么您的 displayNum 将具有 167.16

的价值