src/main/java/com/yeshi/buwan/util/ExcelReadUtil.java
@@ -1,112 +1,5 @@
package com.yeshi.buwan.util;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.yeshi.buwan.domain.LeShiAccountVideo;
import com.yeshi.buwan.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");
            // juhe.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;
   }
}