润乾报表处理小数位多余0

左手的ㄟ右手 2022-09-16 11:22 273阅读 0赞

sql方法,to_char

这种有缺陷,没解决问题

润乾指定单元格格式

这种也有问题,只能指定截取几位

润乾round等函数

这种也只能指定截取几位

所以考虑换种优雅的方式实现截取多余0

下面是针对6位小数的截取

  1. if(pos(string(ds1.breaking_elongation_std),".")==null,ds1.breaking_elongation_std,
  2. if(right(string(ds1.breaking_elongation_std),6)=="000000",round(ds1.breaking_elongation_std,0),
  3. (if(right(string(ds1.breaking_elongation_std),5)=="00000",round(ds1.breaking_elongation_std,1),
  4. (if(right(string(ds1.breaking_elongation_std),4)=="0000",round(ds1.breaking_elongation_std,2),
  5. (if(right(string(ds1.breaking_elongation_std),3)=="000",round(ds1.breaking_elongation_std,3),
  6. (if(right(string(ds1.breaking_elongation_std),2)=="00",round(ds1.breaking_elongation_std,4),
  7. (if(right(string(ds1.breaking_elongation_std),1)=="0",round(ds1.breaking_elongation_std,5),ds1.breaking_elongation_std))
  8. )
  9. )
  10. )
  11. )
  12. )
  13. )
  14. )
  15. )
  16. )
  17. )

虽然代码不优雅,但是实现了优雅的截取。

将ds1.breaking_elongation_std换成你自己的字段即可。

发表评论

表情:
评论列表 (有 0 条评论,273人围观)

还没有评论,来说两句吧...

相关阅读