gpt4 book ai didi

Java JXL API如何为数字添加小数分隔符

转载 作者:行者123 更新时间:2023-12-01 04:30:07 26 4
gpt4 key购买 nike

我正在使用jxl将一个小jtable导出到excel,并且我选择JXL API来实现我的目标,一切都很顺利。但我仍然有一个关于数字格式的小问题:

如何添加小数点分隔符,如下例所示:

------------------------
2365897412
------------------------

------------------------
2 365 897 412
------------------------

非常感谢

最佳答案

NumberFormat nf=new NumberFormat("#,###.###");                   // this format constraints the number upto 3 decimal points
WritableCellFormat cf2obj=new WritableCellFormat(nf);
numobj=new Number(2,1,3698745896546.353454,cf2obj);
sheet.addCell(numobj);

Excel 工作表中的输出如下所示

3 698 745 896 546,35

谢谢

关于Java JXL API如何为数字添加小数分隔符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18055776/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com