EaysPoi导出的时候文本格式设置为数值
- EasyPOI
- 时间:2021-07-21 06:47
- 5143人已阅读
简介
场景导出的数值单元格格式是文本。客户每次都要手动转为数值,往往一个表格就是好多万数据,转换起来等半天。解决方案听说@Excel设置type=10即可POM引入easyPoi相关的:<!-- easyExcel start --><dependency> <groupId>com.alib
🔔🔔🔔好消息!好消息!🔔🔔🔔
有需要的朋友👉:联系凯哥
场景
解决方案
听说@Excel 设置type=10即可
<!-- easyExcel start --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.9</version> </dependency> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-web</artifactId> <!--<version>4.3.0</version>--> <version>3.2.0</version> </dependency> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-base</artifactId> <!--<version>4.3.0</version>--> <version>3.2.0</version> </dependency> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-annotation</artifactId> <!--<version>4.3.0</version>--> <version>3.2.0</version> </dependency> <!-- easyExcel end -->
应用:
需要注意的是:
如果format成 【#,##0,00】有可能提示字符串转换异常的。如下图:
解决方案:修改format格式。easyPOI支持的format格式如下:
easypoi支持的自定义格式列表
private final static String[] _formats = { "General", "0", "0.00", "#,##0", "#,##0.00", "\"$\"#,##0_);(\"$\"#,##0)", "\"$\"#,##0_);[Red](\"$\"#,##0)", "\"$\"#,##0.00_);(\"$\"#,##0.00)", "\"$\"#,##0.00_);[Red](\"$\"#,##0.00)", "0%", "0.00%", "0.00E+00", "# ?/?", "# ??/??", "m/d/yy", "d-mmm-yy", "d-mmm", "mmm-yy", "h:mm AM/PM", "h:mm:ss AM/PM", "h:mm", "h:mm:ss", "m/d/yy h:mm", // 0x17 - 0x24 reserved for international and undocumented // TODO - one junit relies on these values which seems incorrect "reserved-0x17", "reserved-0x18", "reserved-0x19", "reserved-0x1A", "reserved-0x1B", "reserved-0x1C", "reserved-0x1D", "reserved-0x1E", "reserved-0x1F", "reserved-0x20", "reserved-0x21", "reserved-0x22", "reserved-0x23", "reserved-0x24", "#,##0_);(#,##0)", "#,##0_);[Red](#,##0)", "#,##0.00_);(#,##0.00)", "#,##0.00_);[Red](#,##0.00)", "_(* #,##0_);_(* (#,##0);_(* \"-\"_);_(@_)", "_(\"$\"* #,##0_);_(\"$\"* (#,##0);_(\"$\"* \"-\"_);_(@_)", "_(* #,##0.00_);_(* (#,##0.00);_(* \"-\"??_);_(@_)", "_(\"$\"* #,##0.00_);_(\"$\"* (#,##0.00);_(\"$\"* \"-\"??_);_(@_)", "mm:ss", "[h]:mm:ss", "mm:ss.0", "##0.0E+0", "@" };
上一篇: 自测规范