Excel 文件(来自 DataGridView)未显示 'Zero' 值 < 1
Excel file (from DataGridView) not showing 'Zero' for values < 1
我正在将 DataGridView 导出到 Excel 文件。
DGV 包含一个包含货币 (€) 的列,因此我使用此代码来格式化 Excel Sheet 列:
With xlSheet
.Range(.Cells(1, C + 1), .Cells(1, C + 1)).EntireColumn.NumberFormat = "€ #,###,###.00"
End With
但是,当我打开保存的 excel 文件时,如果值小于 1(即 0,25),我得到:
€ ,25
而不是
€ 0,25
我该如何解决?
在您的数字格式中的小数点前添加一个零:
With xlSheet
.Range(.Cells(1, C + 1), .Cells(1, C + 1)).EntireColumn.NumberFormat = "€ #,###,##0.00"
End With
0 (zero) -- This digit placeholder displays insignificant zeros if a number has fewer digits than there are zeros in the format. For example, if you type 8.9, and you want it to be displayed as 8.90, use the format #.00.
我正在将 DataGridView 导出到 Excel 文件。
DGV 包含一个包含货币 (€) 的列,因此我使用此代码来格式化 Excel Sheet 列:
With xlSheet
.Range(.Cells(1, C + 1), .Cells(1, C + 1)).EntireColumn.NumberFormat = "€ #,###,###.00"
End With
但是,当我打开保存的 excel 文件时,如果值小于 1(即 0,25),我得到:
€ ,25
而不是
€ 0,25
我该如何解决?
在您的数字格式中的小数点前添加一个零:
With xlSheet
.Range(.Cells(1, C + 1), .Cells(1, C + 1)).EntireColumn.NumberFormat = "€ #,###,##0.00"
End With
0 (zero) -- This digit placeholder displays insignificant zeros if a number has fewer digits than there are zeros in the format. For example, if you type 8.9, and you want it to be displayed as 8.90, use the format #.00.