/** * 处理excel数据的方法 */ public static Hashtable>> readExcel( String filePath) throws Exception { Hashtable >> datas = new Hashtable >>(); InputStream is = null; try { is = new FileInputStream(filePath); WorkbookSettings wkbkSet = new WorkbookSettings(); wkbkSet.setSuppressWarnings(true); Workbook rwb = Workbook.getWorkbook(is, wkbkSet); Sheet st[] = rwb.getSheets(); for (int a = 0; a < st.length; a++) { String sheetName = st[a].getName().trim(); Vector > sheetDatas = new Vector >(); for (int i = 0; i < st[a].getRows(); i++) { Vector rowDatas = new Vector (); for (int j = 0; j < st[a].getColumns(); j++) { Cell c = st[a].getCell(j, i); String content = c.getContents().trim(); rowDatas.add(content); } sheetDatas.add(rowDatas); } datas.put(sheetName, sheetDatas); } rwb.close(); } catch (Exception e) { throw e; } finally { try { if (is != null) { is.close(); } } catch (Exception e) { } } return datas; } public static void main(String[] args) throws Exception { Hashtable >> datas = readExcel("E:\\123.xls"); System.out.println(datas.get("Sheet1")); }