首页 > 代码库 > jxl操作Excel
jxl操作Excel
/** * 处理excel数据的方法 */ public static Hashtable<String, Vector<Vector<String>>> readExcel( String filePath) throws Exception { Hashtable<String, Vector<Vector<String>>> datas = new Hashtable<String, Vector<Vector<String>>>(); 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<Vector<String>> sheetDatas = new Vector<Vector<String>>(); for (int i = 0; i < st[a].getRows(); i++) { Vector<String> rowDatas = new Vector<String>(); 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<String, Vector<Vector<String>>> datas = readExcel("E:\\123.xls"); System.out.println(datas.get("Sheet1")); }
jxl操作Excel
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。