admin
2021-01-25 d182390205a9828bd1091b06fa712e028004c687
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package com.newvideo.util;
 
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
 
import com.newvideo.domain.LeShiAccountVideo;
import com.newvideo.domain.entity.VideoAccount;
 
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
 
public class ExcelReadUtil {
 
    public static List<LeShiAccountVideo> getLeShiAccountFromExcel(int start,
            int end) {
        List<LeShiAccountVideo> list = new ArrayList<LeShiAccountVideo>();
        try {
            String fileName = "C:/Users/Administrator/Desktop/影片本地表.xls"; // Excel文件所在路径
            File file = new File(fileName); // 创建文件对象
            Workbook wb = Workbook.getWorkbook(file); // 从文件流中获取Excel工作区对象(WorkBook)
            Sheet sheet = wb.getSheet(0); // 从工作区中取得页(Sheet)
 
            for (int i = start - 1; i < end; i++) { // 循环打印Excel表中的内容
                Cell cell = sheet.getCell(0, i);
                Cell cell1 = sheet.getCell(1, i);
                Cell cell2 = sheet.getCell(2, i);
                LeShiAccountVideo video = new LeShiAccountVideo();
                video.setAccount(cell.getContents().trim() + "@"
                        + cell1.getContents().trim());
                video.setPwd(cell2.getContents().trim());
                video.setState("0");
                video.setValid("0");
                video.setDetailId("0");
                video.setUsecount("0");
                // video.setRegisterip().trim());
                list.add(video);
                LogUtil.i(cell.getContents());
            }
        } catch (BiffException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return list;
    }
 
    public static List<VideoAccount> getRegisterLeShiAccountFromExcel(
            int start, int count) {
        List<VideoAccount> list = new ArrayList<VideoAccount>();
        try {
            String fileName = "C:/Users/Administrator/Desktop/影片本地表.xls"; // Excel文件所在路径
            File file = new File(fileName); // 创建文件对象
            Workbook wb = Workbook.getWorkbook(file); // 从文件流中获取Excel工作区对象(WorkBook)
            Sheet sheet = wb.getSheet(0); // 从工作区中取得页(Sheet)
 
            for (int i = start - 1; i < 1 + start + count; i++) { // 循环打印Excel表中的内容
                Cell cell = sheet.getCell(0, i);// 账号
                Cell cell1 = sheet.getCell(1, i);// 账号
                Cell cell2 = sheet.getCell(2, i);// 账号
                Cell cell3 = sheet.getCell(5, i);// 账号
                String account = cell.getContents() + "@" + cell1.getContents();
                String pwd = cell2.getContents();
                String url = cell3.getContents();
                VideoAccount video = new VideoAccount();
                video.setAccount(account);
                video.setName(pwd);
                video.setBeizhu(url);
                // if (url != null && url.length() > 20)
                list.add(video);
                LogUtil.i(cell.getContents());
            }
        } catch (BiffException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return list;
    }
 
    public static List<VideoAccount> getLeShiAccount(String filePath,
            int start, int end) {
        List<VideoAccount> list = new ArrayList<VideoAccount>();
        try {
            String fileName = filePath; // Excel文件所在路径
            File file = new File(fileName); // 创建文件对象
            Workbook wb = Workbook.getWorkbook(file); // 从文件流中获取Excel工作区对象(WorkBook)
            Sheet sheet = wb.getSheet(0); // 从工作区中取得页(Sheet)
 
            for (int i = start; i < end; i++) { // 循环打印Excel表中的内容
                Cell cell = sheet.getCell(0, i);// 账号
                Cell cell1 = sheet.getCell(3, i);// 密码
                String account = cell.getContents();
                String pwd = cell1.getContents();
                VideoAccount video = new VideoAccount();
                video.setAccount(account);
                video.setName(pwd);
                if (!StringUtil.isNullOrEmpty(account))
                    list.add(video);
                LogUtil.i(account);
            }
        } catch (BiffException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return list;
    }
}