示例#1
0
  /**
   * Fired when the document is written to an output stream.
   *
   * @see org.apache.poi.xssf.usermodel.XSSFSheet#write(java.io.OutputStream) ()
   */
  protected void onDocumentWrite() {
    // check if cells in the CTRow are ordered
    boolean isOrdered = true;
    if (_row.sizeOfCArray() != _cells.size()) isOrdered = false;
    else {
      int i = 0;
      CTCell[] xcell = _row.getCArray();
      for (XSSFCell cell : _cells.values()) {
        CTCell c1 = cell.getCTCell();
        CTCell c2 = xcell[i++];

        String r1 = c1.getR();
        String r2 = c2.getR();
        if (!(r1 == null ? r2 == null : r1.equals(r2))) {
          isOrdered = false;
          break;
        }
      }
    }

    if (!isOrdered) {
      CTCell[] cArray = new CTCell[_cells.size()];
      int i = 0;
      for (XSSFCell c : _cells.values()) {
        cArray[i++] = c.getCTCell();
      }
      _row.setCArray(cArray);
    }
  }
示例#2
0
 /**
  * Construct a XSSFRow.
  *
  * @param row the xml bean containing all cell definitions for this row.
  * @param sheet the parent sheet.
  */
 protected XSSFRow(CTRow row, XSSFSheet sheet) {
   _row = row;
   _sheet = sheet;
   _cells = new TreeMap<Integer, XSSFCell>();
   for (CTCell c : row.getCArray()) {
     XSSFCell cell = new XSSFCell(this, c);
     _cells.put(cell.getColumnIndex(), cell);
     sheet.onReadCell(cell);
   }
 }