简体   繁体   中英

How to remove trailing zero?

i use jxl.write.WritableCellFormat.WritableCellFormat when I download Excel.

Excel download is fine.

But cellFormatStyle does not come out the way I want.

-now problem 1 -> 1.000 0.003 -> 0.003

-i want 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. So assuming your data is in cell 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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