/** Dumps out the contents of the excel file */
  private void display(WorkbookSettings ws) throws IOException {
    Record r = null;
    boolean found = false;
    while (reader.hasNext() && !found) {
      r = reader.next();
      if (r.getType() == Type.WRITEACCESS) {
        found = true;
      }
    }

    if (!found) {
      System.err.println("Warning:  could not find write access record");
      return;
    }

    byte[] data = r.getData();

    String s = null;

    s = StringHelper.getString(data, data.length, 0, ws);

    System.out.println(s);
  }
  /**
   * Gets the name of the external sheet specified by the index
   *
   * @param index the external sheet index
   * @return the name of the external sheet
   */
  public String getExternalSheetName(int index) {
    // For biff7, the whole external reference thing works differently
    // Hopefully for our purposes sheet references will all be local
    if (workbookBof.isBiff7()) {
      BoundsheetRecord br = (BoundsheetRecord) boundsheets.get(index);

      return br.getName();
    }

    int supbookIndex = externSheet.getSupbookIndex(index);
    SupbookRecord sr = (SupbookRecord) supbooks.get(supbookIndex);

    int firstTab = externSheet.getFirstTabIndex(index);
    int lastTab = externSheet.getLastTabIndex(index);
    String firstTabName = "";
    String lastTabName = "";

    if (sr.getType() == SupbookRecord.INTERNAL) {
      // It's an internal reference - get the name from the boundsheets list
      if (firstTab == 65535) {
        firstTabName = "#REF";
      } else {
        BoundsheetRecord br = (BoundsheetRecord) boundsheets.get(firstTab);
        firstTabName = br.getName();
      }

      if (lastTab == 65535) {
        lastTabName = "#REF";
      } else {
        BoundsheetRecord br = (BoundsheetRecord) boundsheets.get(lastTab);
        lastTabName = br.getName();
      }

      String sheetName = (firstTab == lastTab) ? firstTabName : firstTabName + ':' + lastTabName;

      // if the sheet name contains apostrophes then escape them
      sheetName =
          sheetName.indexOf('\'') == -1 ? sheetName : StringHelper.replace(sheetName, "\'", "\'\'");

      // if the sheet name contains spaces, then enclose in quotes
      return sheetName.indexOf(' ') == -1 ? sheetName : '\'' + sheetName + '\'';
    } else if (sr.getType() == SupbookRecord.EXTERNAL) {
      // External reference - get the sheet name from the supbook record
      StringBuffer sb = new StringBuffer();
      java.io.File fl = new java.io.File(sr.getFileName());
      sb.append("'");
      sb.append(fl.getAbsolutePath());
      sb.append("[");
      sb.append(fl.getName());
      sb.append("]");
      sb.append((firstTab == 65535) ? "#REF" : sr.getSheetName(firstTab));
      if (lastTab != firstTab) {
        sb.append(sr.getSheetName(lastTab));
      }
      sb.append("'");
      return sb.toString();
    }

    // An unknown supbook - return unkown
    logger.warn("Unknown Supbook 3");
    return "[UNKNOWN]";
  }