java - 如何删除尾随零?
问题描述
我jxl.write.WritableCellFormat.WritableCellFormat
在下载 Excel 时使用。
Excel下载很好。
但是 cellFormatStyle 并没有按照我想要的方式出现。
- 现在问题 1 -> 1.000 0.003 -> 0.003
-我想要 1 -> 1 0.003 -> 0.003
我应该怎么办??请帮助我。
下面是问题的代码。
NumberFormat numberFormat = new NumberFormat("0.###")
WritableCellFormat cellStyle = new WritableCellFormat(numberFormat);
解决方案
您可以检查右 4 个字符是否小于零,如果不是,则更改数字格式。因此,假设您的数据在单元格 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
推荐阅读
- c# - 如何向我的 API (MVC) 添加多个过滤器
- python - Python:如何在具有特定值时创建具有第一行的新数据框
- javascript - 在jquery php ajax中循环遍历js数组
- asp.net-mvc - asp.net核心选项元素中的三元运算符
- webstorm - 到处隐藏正在搜索的课程
- java - 如何在 Jmeter 中创建随机列表名称并在不同线程中使用 - Jmeter
- c++ - 有人可以帮助我使用正则表达式吗?
- java - 从原点到点的路径数
- java - 为什么递归 MergeSort 比迭代 MergeSort 快?
- scala - Apache Flink Scala 流式处理