Browse Source

poi 整数类型转成数字格式

tiaosheng
zhizhi wu 5 years ago
parent
commit
9b48f85094
  1. 13
      util/src/main/java/com/ccsens/util/PoiUtil.java

13
util/src/main/java/com/ccsens/util/PoiUtil.java

@ -178,9 +178,14 @@ public class PoiUtil {
CellStyle style = wb.createCellStyle(); CellStyle style = wb.createCellStyle();
//设置内容 //设置内容
if (!WebConstant.CELL_NULL.equals(cell.value)){ if (!WebConstant.CELL_NULL.equals(cell.value)){
if(cell.num == 1){ // if(cell.num == 1){
newCell.setCellValue(Integer.parseInt(cell.value)); // newCell.setCellValue(Integer.parseInt(cell.value));
}else { // }else {
// newCell.setCellValue(cell.value);
// }
if (cell.value.matches("\\d+")) {
newCell.setCellValue(Long.parseLong(cell.value));
} else {
newCell.setCellValue(cell.value); newCell.setCellValue(cell.value);
} }
} }
@ -627,7 +632,7 @@ public class PoiUtil {
PoiUtilCell poiUtilCella = new PoiUtilCell(); PoiUtilCell poiUtilCella = new PoiUtilCell();
PoiUtilCell poiUtilCellb = new PoiUtilCell(); PoiUtilCell poiUtilCellb = new PoiUtilCell();
PoiUtilCell poiUtilCell1 = new PoiUtilCell(); PoiUtilCell poiUtilCell1 = new PoiUtilCell();
poiUtilCell1.setValue("aaadddfffersdfsdfasftargadfgergsdfhasfgasfgaertagaergafdhsfgjfyk"); poiUtilCell1.setValue("1");
List<PoiUtilCell> cells = new ArrayList<>(); List<PoiUtilCell> cells = new ArrayList<>();
cells.add(poiUtilCell); cells.add(poiUtilCell);

Loading…
Cancel
Save