admin
2020-05-20 98b1a0affd69bbe63223c21fdd2c404e8bedfccb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.yeshi.fanli.util;
 
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
 
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
 
public class ExcelUtil {
 
    public static List<String> articelList(String path) {
        List<String> list = new ArrayList<String>();
        try {
            File file = new File(path); // 创建文件对象
            Workbook wb = Workbook.getWorkbook(file); // 从文件流中获取Excel工作区对象(WorkBook
            Sheet sheet = wb.getSheet(0); // 从工作区中取得页(Sheet
 
            for (int i = 0; i < sheet.getRows(); i++) { // 循环打印Excel表中的内
                Cell cell = sheet.getCell(1, i);
                if (!StringUtil.isNullOrEmpty(cell.getContents()))
                    list.add((cell.getContents() + "").trim());
            }
        } catch (BiffException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return list;
    }
 
    public static void updateExcel() {
 
    }
 
}