package youg; import java.io.FileInputStream; import java.io.InputStream; import java.util.Vector; import jxl.Cell; import jxl.Sheet; import jxl.Workbook; public class ReadExcel { //Vector v_identNumber = new Vector(); // 存放读取出来的号码 public Vector<String> readExcel(String filePath) throws Exception { Vector<String> v = new Vector<String>(); // 存放读取出来的姓名和电话 InputStream iStream = null; Workbook workbook = null; iStream = new FileInputStream(filePath); workbook = Workbook.getWorkbook(iStream); // sheet row column 下标都是从0开始的 Sheet sheet = workbook.getSheet(0); int column = sheet.getColumns(); int rows = sheet.getRows(); System.out.println("共有" + rows + "行," + column + "列数据"); for (int i = 1; i < rows; i++) { Cell[] cells = sheet.getRow(i); //System.out.println(cells[0].getContents()); v.add(cells[0].getContents()); v.add(cells[1].getContents()); //System.out.println(cells[1].getContents()); //v_identNumber.add(cells[1].getContents()); //System.out.println(cells[2].getContents()); //System.out.println(cells[3].getContents()); } // 操作完成时,关闭对象,释放占用的内存空间 if (iStream != null) iStream.close(); if (workbook != null) workbook.close(); return v; } /** * @param args * @throws Exception */ // public static void main(String[] args) throws Exception { // String filePath = "D:\\testreadexcel.xls"; // ReadExcel readExcel = new ReadExcel(); // readExcel.readExcel(filePath).toString(); // // } }
最近下载更多
jiangqiang LV12
1月16日
大神程序员 LV22
1月12日
fdo666 LV6
1月10日
sdfsdfsfsd LV1
1月9日
fesfefe LV13
2023年11月17日
VignyBear LV2
2023年5月30日
ccc9527 LV1
2022年10月6日
姜广坤 LV14
2022年5月20日
wyx065747 LV67
2022年3月13日
安宇12345 LV15
2022年1月21日
最近浏览更多
860421 LV3
昨天
操作者
4月12日
暂无贡献等级
akittyboy LV9
3月22日
zhenglijuan
3月21日
暂无贡献等级
SZEPEZS LV8
3月11日
DuZhiTong LV1
2月29日
conan_lee LV2
1月29日
MMENGDI LV14
1月18日
3296029180
1月18日
暂无贡献等级
jiangqiang LV12
1月16日