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();
}
}
}