简体   繁体   English

如何删除尾随零?

[英]How to remove trailing zero?

i use jxl.write.WritableCellFormat.WritableCellFormat when I download Excel.我在下载 Excel 时使用jxl.write.WritableCellFormat.WritableCellFormat

Excel download is fine. Excel下载没问题。

But cellFormatStyle does not come out the way I want.但是 cellFormatStyle 并没有按照我想要的方式出现。

-now problem 1 -> 1.000 0.003 -> 0.003 - 现在问题 1 -> 1.000 0.003 -> 0.003

-i want 1 -> 1 0.003 -> 0.003 -我想要 1 -> 1 0.003 -> 0.003

What should I do??我该怎么办?? plz help me.请帮助我。

Below is the code of the problem.下面是问题的代码。

NumberFormat numberFormat = new NumberFormat("0.###")

WritableCellFormat cellStyle = new WritableCellFormat(numberFormat);

You can check to see if the right 4 characters are less than zero and change the number format if they are not.您可以检查正确的 4 个字符是否小于零,如果不是,则更改数字格式。 So assuming your data is in cell A1:因此,假设您的数据在单元格 A1 中:

If Right(Range("A1"), 4) < 1 Then
Else
'This means it is not < 1 and therefore not a decimal
Range("A1").NumberFormat = "0"
End If

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM