java POI解析Excel 之数据转换公用方法(推荐)
作者:jingxian 时间:2023-06-10 11:04:53
如下所示:
public static String reThreeStr(String ss){
boolean result= ss.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$");
if(result&&ss!=null&&!"".equals(ss)){
Double sss=Double.valueOf(ss);
String numStr=new java.text.DecimalFormat("0.000").format(sss);
Double lsDou=Double.valueOf(numStr);
ss=String.valueOf(lsDou);
}
return ss;
}
public static BigDecimal reThreeBig(BigDecimal ss){
String numStr=new java.text.DecimalFormat("0.000").format(ss);
BigDecimal newNum=new BigDecimal(numStr);
return newNum;
}
public static String delezero(String old){
boolean result= old.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$");
if(result&&old!=null&&!"".equals(old)){
String newStr=old;
if(old.contains(".0")){
old=newStr.substring(0, old.length()-2);
}
return old;
}else{
return old;
}
}
标签:java,poi,excel
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Android多渠道打包的方法步骤
2022-10-17 12:05:07
![](https://img.aspxhome.com/file/2023/4/91024_0s.png)
Java设计模式之观察者模式(Observer模式)介绍
2022-10-16 04:40:42
![](https://img.aspxhome.com/file/2023/2/82002_0s.png)
springboot日期转换器实现实例解析
2023-01-31 13:16:45
![](https://img.aspxhome.com/file/2023/1/67151_0s.png)
C#动态创建button的方法
2023-02-11 15:58:26
浅析C# 9.0 新特性之 Lambda 弃元参数
2022-05-08 16:28:22
![](https://img.aspxhome.com/file/2023/9/119569_0s.png)
android解析JSON数据
2022-10-17 04:55:40
java如何反编译jar包并修改class文件重新打包
2021-09-20 05:24:26
![](https://img.aspxhome.com/file/2023/3/81933_0s.jpg)
一款适用于Android平台的俄罗斯方块
2023-02-25 02:38:35
![](https://img.aspxhome.com/file/2023/2/122062_0s.jpg)
Mybatis动态调用表名和字段名的解决方法
2022-03-18 16:54:14
Mybatis实现关联关系映射的方法示例
2022-09-18 05:36:12
![](https://img.aspxhome.com/file/2023/9/128909_0s.jpg)
android实现注册登录程序
2021-06-28 00:38:44
Android开发之使用ViewPager实现图片左右滑动切换效果
2022-11-12 11:44:59
java生成图片验证码实例代码
2022-01-06 04:01:37
ehcache模糊批量移除缓存的方法
2023-01-11 12:30:37
Spring与Mybatis基于注解整合Redis的方法
2022-09-19 09:19:56
![](https://img.aspxhome.com/file/2023/5/61075_0s.png)
基于C#实现获取本地磁盘目录
2021-08-21 12:51:43
![](https://img.aspxhome.com/file/2023/3/129753_0s.png)
详解mybatis-plus配置找不到Mapper接口路径的坑
2022-03-12 10:37:45
![](https://img.aspxhome.com/file/2023/1/129171_0s.png)
C#调用Oracle存储过程的方法
2022-10-19 02:29:19
Java中Date和Calendar常用方法
2023-11-12 07:35:32
IDEA安装阿里巴巴编码规范插件的两种方式详解(在线安装和离线安装)
2022-07-23 19:18:54
![](https://img.aspxhome.com/file/2023/9/60379_0s.png)