读取EXCEL

package com.wxgs.ch04;

import java.io.File;
import java.io.IOException;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class ExcelTest {
static String getExcel(String bb){
String a="";
try {
Workbook book=Workbook.getWorkbook(new File(bb));
//获得第一个工作对象
Sheet sheet=book.getSheet(0);
//得到第一列
Cell cell1=sheet.getCell(0,0);
a=cell1.getContents();
} catch (BiffException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return a;
}
public static void main(String[] args) {
String a=getExcel("d:/a.xls");
System.out.println(a);
}
}

posted @ 2015-08-25 21:19  小祥工作室  阅读(188)  评论(0编辑  收藏  举报