예제 #1
0
  /**
   * Compares two <code>XSSFRow</code> objects. Two rows are equal if they belong to the same
   * worksheet and their row indexes are equal.
   *
   * @param row the <code>XSSFRow</code> to be compared.
   * @return the value <code>0</code> if the row number of this <code>XSSFRow</code> is equal to the
   *     row number of the argument <code>XSSFRow</code>; a value less than <code>0</code> if the
   *     row number of this this <code>XSSFRow</code> is numerically less than the row number of the
   *     argument <code>XSSFRow</code>; and a value greater than <code>0</code> if the row number of
   *     this this <code>XSSFRow</code> is numerically greater than the row number of the argument
   *     <code>XSSFRow</code>.
   * @throws IllegalArgumentException if the argument row belongs to a different worksheet
   */
  public int compareTo(XSSFRow row) {
    int thisVal = this.getRowNum();
    if (row.getSheet() != getSheet())
      throw new IllegalArgumentException("The compared rows must belong to the same XSSFSheet");

    int anotherVal = row.getRowNum();
    return (thisVal < anotherVal ? -1 : (thisVal == anotherVal ? 0 : 1));
  }
  private XSSFRow createRowFrom(IRecordable o) {
    XSSFRow lastRow, r;
    String[] data;

    if (dicoLocations.containsKey(o.getClassement()))
      lastRow = dicoLocations.get(o.getClassement());
    else {
      XSSFSheet logSheet = wb.createSheet(o.getClassement());
      lastRow = logSheet.createRow(0);
      data = o.getTitles();
      fillRowWith(lastRow, data);
      dicoLocations.put(o.getClassement(), lastRow);
    }
    r = lastRow.getSheet().createRow(lastRow.getRowNum() + 1);
    data = o.getRecords();
    fillRowWith(r, data);
    dicoLocations.replace(o.getClassement(), r);
    return r;
  }