⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rowrecord.java

📁 jxtl API Java中Excel的生成与导入解析参考文档
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    else
    {
      // Write out as number records
      Iterator i = integerValues.iterator();
      while (i.hasNext())
      {
        outputFile.write((CellValue) i.next());
      }
    }

    // Clear out the list of integerValues
    integerValues.clear();
  }

  /**
   * Gets the row data to output to file
   * 
   * @return the binary data
   */
  public byte[] getData()
  {
    // Write out the row record
    byte[] data = new byte[16];

    // If the default row height has been changed in the sheet settings,
    // then we need to set the rowHeight on this row explicitly, as 
    // specifying the "match default" flag doesn't work
    int rh = rowHeight;
    if (sheet.getSettings().getDefaultRowHeight() != 
        SheetSettings.DEFAULT_DEFAULT_ROW_HEIGHT)
    {
      // the default row height has been changed.  If this row does not
      // have a specific row height set on it, then set it to the default
      if (rh == defaultHeightIndicator)
      {
        rh = sheet.getSettings().getDefaultRowHeight();
      }
    }

    IntegerHelper.getTwoBytes(rowNumber, data, 0);
    IntegerHelper.getTwoBytes(numColumns, data, 4);
    IntegerHelper.getTwoBytes(rh, data, 6);

    int options = 0x100 + outlineLevel;

    if (groupStart)
    {
      options |= 0x10;
    }

    if (collapsed)
    {
      options |= 0x20;
    }

    if (!matchesDefFontHeight)
    {
      options |= 0x40;
    }

    if (defaultFormat)
    {
      options |= 0x80;
      options |= (xfIndex << 16);
    }

    IntegerHelper.getFourBytes(options, data, 12);
    
    return data;
  }

  /**
   * Gets the maximum column value which occurs in this row
   * 
   * @return the maximum column value
   */
  public int getMaxColumn()
  {
    return numColumns;
  }

  /**
   * Gets the cell which occurs at the specified column value
   * 
   * @param col the colun for which to return the cell
   * @return the cell value at the specified position, or null if the column 
   *     is invalid
   */
  public CellValue getCell(int col)
  {
    return (col >= 0 && col < numColumns) ? cells[col] : null;
  }

  /**
   * Increments the row of this cell by one.  Invoked by the sheet when 
   * inserting rows
   */
  void incrementRow()
  {
    rowNumber++;

    for (int i = 0; i < cells.length; i++)
    {
      if (cells[i] != null)
      {
        cells[i].incrementRow();
      }
    }
  }

  /**
   * Decrements the row of this cell by one.  Invoked by the sheet when 
   * removing rows
   */
  void decrementRow()
  {
    rowNumber--;
    for (int i = 0; i < cells.length; i++)
    {
      if (cells[i] != null)
      {
        cells[i].decrementRow();
      }
    }
  }

  /**
   * Inserts a new column at the position specified
   *
   * @param col the column to insert
   */
  void insertColumn(int col)
  {
    // Don't bother doing anything unless there are cells after the
    // column to be inserted
    if (col >= numColumns)
    {
      return;
    }

    if (numColumns >= maxColumns)
    {
      logger.warn("Could not insert column because maximum column limit has "+
                  "been reached");
      return;
    }

    // Create a new array to hold the new column.  Grow it if need be
    CellValue[] oldCells = cells;

    if (numColumns  >= cells.length - 1)
    {
      cells = new CellValue[oldCells.length + growSize];
    }
    else
    {
      cells = new CellValue[oldCells.length];
    }

    // Copy in everything up to the new column
    System.arraycopy(oldCells, 0, cells, 0, col);
    
    // Copy in the remaining cells
    System.arraycopy(oldCells, col, cells, col+1, numColumns - col);

    // Increment all the internal column numbers by one
    for (int i = col+1; i <= numColumns; i++)
    {
      if (cells[i] != null)
      {
        cells[i].incrementColumn();
      }
    }

    // Adjust the maximum column record
    numColumns++;
  }

  /**
   * Remove the new column at the position specified
   *
   * @param col the column to remove
   */
  void removeColumn(int col)
  {
    // Don't bother doing anything unless there are cells after the
    // column to be inserted
    if (col >= numColumns)
    {
      return;
    }

    // Create a new array to hold the new columns
    CellValue[] oldCells = cells;

    cells = new CellValue[oldCells.length];

    // Copy in everything up to the column
    System.arraycopy(oldCells, 0, cells, 0, col);
    
    // Copy in the remaining cells after the column
    System.arraycopy(oldCells, col + 1, cells, col, numColumns - (col+1));

    // Decrement all the internal column numbers by one
    for (int i = col; i < numColumns; i++)
    {
      if (cells[i] != null)
      {
        cells[i].decrementColumn();
      }
    }

    // Adjust the maximum column record
    numColumns--;
  }

  /**
   * Interrogates whether this row is of default height
   *
   * @return TRUE if this is set to the default height, FALSE otherwise
   */
  public boolean isDefaultHeight()
  {
    return rowHeight == defaultHeightIndicator;
  }

  /**
   * Gets the height of the row
   *
   * @return the row height
   */
  public int getRowHeight()
  {
    return rowHeight;
  }

  /**
   * Queries whether the row is collapsed
   *
   * @return the collapsed indicator
   */
  public boolean isCollapsed()
  {
    return collapsed;
  }

  /**
   * Rationalizes the sheets xf index mapping
   * @param xfmapping the index mapping
   */
  void rationalize(IndexMapping xfmapping)
  {
    if (defaultFormat)
    {
      xfIndex = xfmapping.getNewIndex(xfIndex);
    }
  }

  /**
   * Accessor for the style.  The returned value is only non-null if the
   * default style is overridden
   *
   * @return the style
   */
  XFRecord getStyle()
  {
    return style;
  }

  /**
   * Accessor for the default format flag
   *
   * @return TRUE if this row has its own default format
   */
  boolean hasDefaultFormat()
  {
    return defaultFormat;
  }

  /**
   * Accessor for the matches default font height  flag
   *
   * @return TRUE if this row matches the default font height
   */
  boolean matchesDefaultFontHeight()
  {
    return matchesDefFontHeight;
  }

  /** 
   * Accessor for the column's outline level
   *
   * @return the column's outline level
   */
  public int getOutlineLevel() 
  {
    return outlineLevel;
  }

  /** 
   * Accessor for row's groupStart state
   *
   * @return the row's groupStart state
   */
  public boolean getGroupStart() 
  {
    return groupStart;
  }

  /** 
   * Increments the row's outline level.  This is how groups are made as well
   */
  public void incrementOutlineLevel() 
  {
    outlineLevel++;
  }

  /** 
   * Decrements the row's outline level.  This removes it from a grouping 
   * level.  If
   *  all outline levels are gone the uncollapse the row.
   */
  public void decrementOutlineLevel() 
  {
    if (0 < outlineLevel)
    {
      outlineLevel--;
    }

    if (0==outlineLevel)
    {
      collapsed = false;
    }
  }

  /** 
   * Sets the row's outline level
   *
   * @param level the row's outline level
   */
  public void setOutlineLevel(int level) 
  {
    outlineLevel = level;
  }

  /**
   *  Sets the row's group start state
   *
   * @param value the group start state
   */
  public void setGroupStart(boolean value) 
  {
    groupStart = value;
  }
}










⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -