/** * 取得当前sheet的sheet名 * * @return */ public String getSheetName() { if (readOnlyWBook == true) { return currentSheet.getName(); } else { return wrCurrentSheet.getName(); } }
/** * @param ws * @param numrow * @param contentList * @return */ public static boolean writebyrow(WritableSheet ws, int numrow, ArrayList contentList) { try { for (int i = 0; i < contentList.size(); i++) { System.out.println(".....ws=" + ws.getName()); String cellcontent = (String) contentList.get(i); System.out.println(".....cellcontent=" + cellcontent); jxl.write.Label labelC = new jxl.write.Label(i, numrow, cellcontent); ws.addCell(labelC); } } catch (Exception e) { System.out.println("Exception is " + e); } return true; }
/** * @param filename * @param targetsheetname * @return * @throws BiffException * @throws FileNotFoundException * @throws IOException */ public WritableSheet getWritableWookbook(String filename, String targetsheetname) throws BiffException, FileNotFoundException, IOException { Workbook wb = Workbook.getWorkbook(new FileInputStream(filename)); WritableWorkbook wwb = Workbook.createWorkbook(new File(newfilename), wb); WritableSheet ws = null; for (int numSheets = 0; numSheets < wwb.getNumberOfSheets(); numSheets++) { ws = wwb.getSheet(numSheets); String sheetName = ws.getName(); if (sheetName == null || sheetName == "") { break; } System.out.println("sheetName=" + sheetName); System.out.println("targetsheetname=" + targetsheetname); if (sheetName.equals(targetsheetname)) { System.out.println(".........ws=" + ws); return ws; } } return null; }