Esempio n. 1
0
  /** Closes this workbook, and frees makes any memory allocated available for garbage collection */
  public void close() {
    if (lastSheet != null) {
      lastSheet.clear();
    }
    excelFile.clear();

    if (!settings.getGCDisabled()) {
      System.gc();
    }
  }
Esempio n. 2
0
  /**
   * Gets the specified sheet within this workbook
   *
   * @param index the zero based index of the required sheet
   * @return The sheet specified by the index
   */
  public Sheet getSheet(int index) {
    // First see if the last sheet index is the same as this sheet index.
    // If so, then the same sheet is being re-requested, so simply
    // return it instead of rereading it
    if ((lastSheet != null) && lastSheetIndex == index) {
      return lastSheet;
    }

    // Flush out all of the cached data in the last sheet
    if (lastSheet != null) {
      lastSheet.clear();

      if (!settings.getGCDisabled()) {
        System.gc();
      }
    }

    lastSheet = (SheetImpl) sheets.get(index);
    lastSheetIndex = index;
    lastSheet.readSheet();

    return lastSheet;
  }