gpt4 book ai didi

java - 无法使用 POI 应用特定的单元格数据格式

转载 作者:太空宇宙 更新时间:2023-11-04 13:56:47 25 4
gpt4 key购买 nike

我正在使用 Apache POI 将数据写入 Excel。我正在尝试将一个大的十进制数写入 Excel 单元格,并且我正在使用以下方法:

#1:

CellStyle style= wb.createCellStyle();
style.setDataFormat(df.getFormat("000.0000000"));

#2:

CellStyle style= wb.createCellStyle();
HSSFCreationHelper createHelper = wb.getCreationHelper();
style.setDataFormat(
createHelper.createDataFormat().getFormat("000.0000000"));

以下是所需的格式:

0.0000000   ---> 000.0000000
1.0000000 ---> 001.0000000
10.0000000 ---> 010.0000000
101.0068721 ---> 101.0068721
111.0034360 ---> 111.0034360
010.0034526 ---> 010.0034526
100.1452672 ---> 100.1452672

但我最终使用上述数据格式得到以下输出:

0.0000000   ---> 000.0000000
1.0000000 ---> 000.0000000
10.0000000 ---> 000.0000000
101.0068721 ---> 000.0068721
111.0034360 ---> 000.0000000
010.0034526 ---> 000.0034526
100.1452672 ---> 000.1452672

正确的数据格式是什么?

最佳答案

小数点前应使用“#”而不是“0”。因此,您的数据格式应为“##0.0000000”。

关于java - 无法使用 POI 应用特定的单元格数据格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29746385/

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