package com.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import com.pojo.Vo;
import com.sun.org.apache.bcel.internal.classfile.JavaClass;
/**
* @作者 王建明
* @创建日期 Dec 16, 2010
* @创建时间 10:04:52 AM
* @版本号 V 1.0
*/
public class MainTest {
/**
* @param args
*/
public static void main(String[] args) {
// SimpleDateFormat sdf = new SimpleDateFormat(
// "EEE, d MMM yyyy HH:mm:ss z",Locale.US);
// System.out.println(sdf.format(new Date()));
try {
File xslFile = new File("src/com/test/test.xls");
FileInputStream fis = new FileInputStream(xslFile);
// 以上传文件的内容写入服务器
// 从输入流创建Workbook
Workbook rwb = Workbook.getWorkbook(fis);
// Sheet的下标是从0开始的
// 获取第一张Sheet表,获取sheet的长度rwb.getSheets().length
Sheet rs = rwb.getSheet(0);
// 获取Sheet表中所包含的总列数
int rsColumns = rs.getColumns();
// 获取Sheet表中所包含的总行数
int rsRows = rs.getRows();
boolean checkOK = true;
for (int i = 0; i < rsRows; i++) {
Vo vo = new Vo();
for (int j = 0; j < rsColumns; j++) {
try {
Cell cell = rs.getCell(j, i);
String colum = cell.getContents();
if(j==1)
vo.setDssd(colum);
if(j==2)
System.out.println(colum);
} catch (RuntimeException e) {
// TODO Auto-generated catch block
checkOK = false;
e.printStackTrace();
}
}
}
if(checkOK){
}else{
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BiffException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IndexOutOfBoundsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
- 1
- 2
- 3
- 4
- 5
前往页