Commit 3674702696588111548add6694c6fe1e4c1d658d

Authored by 王彬
2 parents 91e42cfa b88e024c
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 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);
... ...