Commit b88e024cac952c33b2b3c253d81363c6985224ab
1 parent
33a3ecf6
Exists in
master
.
Showing
2 changed files
with
10 additions
and
3 deletions
Show diff stats
build.gradle
src/main/java/com/taover/util/UtilExcel.java
... | ... | @@ -23,6 +23,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
23 | 23 | public class UtilExcel { |
24 | 24 | private final static String excel2003L =".xls"; //2003- 版本的excel |
25 | 25 | private final static String excel2007U =".xlsx"; //2007+ 版本的excel |
26 | + private final static String CSV =".csv"; //csv | |
26 | 27 | |
27 | 28 | private final static int maxExcelRowNum = 5000; |
28 | 29 | private final static int maxExcelColumnNum = 50; |
... | ... | @@ -54,7 +55,13 @@ public class UtilExcel { |
54 | 55 | }else{ |
55 | 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 | 65 | throw new Exception("解析的文件格式有误!"); |
59 | 66 | } |
60 | 67 | return wb; |
... | ... | @@ -387,7 +394,7 @@ public class UtilExcel { |
387 | 394 | |
388 | 395 | public static void main(String args[]){ |
389 | 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 | 398 | List<List<Object>> data = null; |
392 | 399 | try { |
393 | 400 | data = UtilExcel.readExcel(filepath); | ... | ... |