Commit 6b3caafde6275be4b5e6adb64dfa43685a22e5e3

Authored by gaoming
1 parent 4ce30fea
Exists in master

excel读取小数保留四位

@@ -59,7 +59,7 @@ uploadArchives { @@ -59,7 +59,7 @@ uploadArchives {
59 authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD) 59 authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
60 } 60 }
61 pom.project { 61 pom.project {
62 - version '1.1.96' 62 + version '1.1.98'
63 artifactId ARTIFACT_Id 63 artifactId ARTIFACT_Id
64 groupId GROUP_ID 64 groupId GROUP_ID
65 packaging TYPE 65 packaging TYPE
src/main/java/com/taover/util/UtilExcel.java
@@ -10,6 +10,7 @@ import java.util.HashMap; @@ -10,6 +10,7 @@ import java.util.HashMap;
10 import java.util.List; 10 import java.util.List;
11 import java.util.Map; 11 import java.util.Map;
12 12
  13 +import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
13 import org.apache.poi.hssf.usermodel.HSSFWorkbook; 14 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
14 import org.apache.poi.openxml4j.util.ZipSecureFile; 15 import org.apache.poi.openxml4j.util.ZipSecureFile;
15 import org.apache.poi.ss.usermodel.Cell; 16 import org.apache.poi.ss.usermodel.Cell;
@@ -413,7 +414,7 @@ public class UtilExcel { @@ -413,7 +414,7 @@ public class UtilExcel {
413 if(end > rowLimit){ 414 if(end > rowLimit){
414 end = rowLimit; 415 end = rowLimit;
415 } 416 }
416 - DecimalFormat df = new DecimalFormat("0.#"); 417 + DecimalFormat df = new DecimalFormat("0.####");
417 for(int i=start; i<end+1; ++i){ 418 for(int i=start; i<end+1; ++i){
418 Row row = sheet.getRow(i); 419 Row row = sheet.getRow(i);
419 if(row == null){ 420 if(row == null){
@@ -520,8 +521,15 @@ public class UtilExcel { @@ -520,8 +521,15 @@ public class UtilExcel {
520 521
521 public static void main(String args[]){ 522 public static void main(String args[]){
522 //String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx"; 523 //String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx";
523 - String filepath = "C:\\Users\\gaoming\\Desktop\\测试返单数量.xlsx";  
524 - //String filepath = "C:\\Users\\EDZ\\Desktop\\aaa.xlsx"; 524 + //String filepath = "C:\\Users\\gaoming\\Desktop\\cccc.xls";
  525 + DecimalFormat df = new DecimalFormat("0.####");
  526 +
  527 + System.out.println(df.format(3.333113F));
  528 + System.out.println(df.format(3.3));
  529 + System.out.println(df.format(3.3300));
  530 +
  531 +
  532 + String filepath = "C:\\Users\\EDZ\\Desktop\\acccc.xls";
525 List<List<Object>> data = null; 533 List<List<Object>> data = null;
526 534
527 try { 535 try {
@@ -545,7 +553,7 @@ public class UtilExcel { @@ -545,7 +553,7 @@ public class UtilExcel {
545 // TODO Auto-generated catch block 553 // TODO Auto-generated catch block
546 e.printStackTrace(); 554 e.printStackTrace();
547 } 555 }
548 - List<Short> styleList = new ArrayList<Short>(); 556 +// List<Short> styleList = new ArrayList<Short>();
549 // for(int i=0; i<data.size(); ++i){ 557 // for(int i=0; i<data.size(); ++i){
550 // if(i == 1)styleList.add(Short.valueOf(HSSFColor.RED.index)); 558 // if(i == 1)styleList.add(Short.valueOf(HSSFColor.RED.index));
551 // else styleList.add(null); 559 // else styleList.add(null);