Commit 3674702696588111548add6694c6fe1e4c1d658d
Exists in
master
Merge branch 'master' of gitlab.taover.com:taov-erp/com-taover-util
Showing
1 changed file
with
9 additions
and
2 deletions
Show diff stats
src/main/java/com/taover/util/UtilExcel.java
@@ -23,6 +23,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; | @@ -23,6 +23,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; | ||
23 | public class UtilExcel { | 23 | public class UtilExcel { |
24 | private final static String excel2003L =".xls"; //2003- 版本的excel | 24 | private final static String excel2003L =".xls"; //2003- 版本的excel |
25 | private final static String excel2007U =".xlsx"; //2007+ 版本的excel | 25 | private final static String excel2007U =".xlsx"; //2007+ 版本的excel |
26 | + private final static String CSV =".csv"; //csv | ||
26 | 27 | ||
27 | private final static int maxExcelRowNum = 5000; | 28 | private final static int maxExcelRowNum = 5000; |
28 | private final static int maxExcelColumnNum = 50; | 29 | private final static int maxExcelColumnNum = 50; |
@@ -54,7 +55,13 @@ public class UtilExcel { | @@ -54,7 +55,13 @@ public class UtilExcel { | ||
54 | }else{ | 55 | }else{ |
55 | wb = new XSSFWorkbook(); //2007+ | 56 | wb = new XSSFWorkbook(); //2007+ |
56 | } | 57 | } |
57 | - }else{ | 58 | + }else if(CSV.equals(fileType.trim().toLowerCase())){ |
59 | + if(isRead){ | ||
60 | + wb = new HSSFWorkbook(new FileInputStream(filePath)); //2003- | ||
61 | + }else{ | ||
62 | + wb = new HSSFWorkbook(); //2003- | ||
63 | + } | ||
64 | + } else{ | ||
58 | throw new Exception("解析的文件格式有误!"); | 65 | throw new Exception("解析的文件格式有误!"); |
59 | } | 66 | } |
60 | return wb; | 67 | return wb; |
@@ -387,7 +394,7 @@ public class UtilExcel { | @@ -387,7 +394,7 @@ public class UtilExcel { | ||
387 | 394 | ||
388 | public static void main(String args[]){ | 395 | public static void main(String args[]){ |
389 | //String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx"; | 396 | //String filepath = "C:\\Users\\root\\Desktop\\千丁-6.27.xlsx"; |
390 | - String filepath = "C:\\Users\\EDZ\\Desktop\\gaoming测试甩单.xls"; | 397 | + String filepath = "C:\\Users\\EDZ\\Desktop\\gaoming测试甩单.csv"; |
391 | List<List<Object>> data = null; | 398 | List<List<Object>> data = null; |
392 | try { | 399 | try { |
393 | data = UtilExcel.readExcel(filepath); | 400 | data = UtilExcel.readExcel(filepath); |