java Excel 导入数据库

package webber.gshdsb.util;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class EX {

public static void dealData(String filepath) throws ParseException {
File xlsFile = new File(filepath);
// 获得工作簿对象
Workbook workbook;
try {
workbook = Workbook.getWorkbook(xlsFile);
Sheet sheet = workbook.getSheet(0);
for (int i = 0; i < sheet.getRows(); i++) {
Cell[] row = sheet.getRow(i);
for (int y = 0; y < row.length; y++) {
String a = row[y].getContents();
System.out.println(a);
}
}
workbook.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BiffException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
String filepath="C:/Users/Administrator/Desktop/zhao.xls";
try {
EX.dealData(filepath);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

上一篇:delphi RAD Studio新版本及路线图 及官方网站 官方 版本发布时间


下一篇:jxl.cell 判断非空