示例#1
0
 /**
  * 取得当前sheet的sheet名
  *
  * @return
  */
 public String getSheetName() {
   if (readOnlyWBook == true) {
     return currentSheet.getName();
   } else {
     return wrCurrentSheet.getName();
   }
 }
示例#2
0
  /**
   * @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;
  }
示例#3
0
  /**
   * @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;
  }