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

📄 cellvalue.java~

📁 jxtl API Java中Excel的生成与导入解析参考文档
💻 JAVA~
📖 第 1 页 / 共 2 页
字号:
   * Increments the row of this cell by one.  Invoked by the sheet when 
   * inserting rows
   */
  void incrementRow()
  {
    row++;

    if (features != null)
    {
      Comment c = features.getCommentDrawing();
      if (c != null)
      {
        c.setX(column);
        c.setY(row);
      }
    }
  }

  /**
   * Decrements the row of this cell by one.  Invoked by the sheet when 
   * removing rows
   */
  void decrementRow()
  {
    row--;

    if (features != null)
    {
      Comment c = features.getCommentDrawing();
      if ( c!= null)
      {
        c.setX(column);
        c.setY(row);
      }

      if (features.hasDropDown())
      {
        logger.warn("need to change value for drop down drawing");
      }
    }
  }

  /**
   * Increments the column of this cell by one.  Invoked by the sheet when 
   * inserting columns
   */
  void incrementColumn()
  {
    column++;

    if (features != null)
    {
      Comment c = features.getCommentDrawing();
      if (c != null)
      {
        c.setX(column);
        c.setY(row);
      }
    }

  }

  /**
   * Decrements the column of this cell by one.  Invoked by the sheet when 
   * removing columns
   */
  void decrementColumn()
  {
    column--;

    if (features != null)
    {
      Comment c = features.getCommentDrawing();
      if (c != null)
      {
        c.setX(column);
        c.setY(row);
      }
    }

  }

  /**
   * Called when a column is inserted on the specified sheet.  Notifies all
   * RCIR cells of this change. The default implementation here does nothing
   *
   * @param s the sheet on which the column was inserted
   * @param sheetIndex the sheet index on which the column was inserted
   * @param col the column number which was inserted
   */
  void columnInserted(Sheet s, int sheetIndex, int col)
  {
  }

  /**
   * Called when a column is removed on the specified sheet.  Notifies all
   * RCIR cells of this change. The default implementation here does nothing
   *
   * @param s the sheet on which the column was inserted
   * @param sheetIndex the sheet index on which the column was inserted
   * @param col the column number which was inserted
   */
  void columnRemoved(Sheet s, int sheetIndex, int col)
  {
  }

  /**
   * Called when a row is inserted on the specified sheet.  Notifies all
   * RCIR cells of this change. The default implementation here does nothing
   *
   * @param s the sheet on which the column was inserted
   * @param sheetIndex the sheet index on which the column was inserted
   * @param row the column number which was inserted
   */
  void rowInserted(Sheet s, int sheetIndex, int row)
  {
  }

  /**
   * Called when a row is inserted on the specified sheet.  Notifies all
   * RCIR cells of this change. The default implementation here does nothing
   *
   * @param s the sheet on which the row was removed
   * @param sheetIndex the sheet index on which the column was removed
   * @param row the column number which was removed
   */
  void rowRemoved(Sheet s, int sheetIndex, int row)
  {
  }

  /**
   * Accessor for the sheet containing this cell
   *
   * @return the sheet containing this cell
   */
  protected WritableSheetImpl getSheet()
  {
    return sheet;
  }

  /**
   * Adds the format information to the shared records.  Performs the necessary
   * checks (and clones) to ensure that the formats are not shared.
   * Called from setCellDetails and setCellFormat
   */
  private void addCellFormat()
  {
    // Check to see if the format is one of the shared Workbook defaults.  If
    // so, then get hold of the Workbook's specific instance
    Styles styles = sheet.getWorkbook().getStyles();
    format = styles.getFormat(format);

    try
    {      
      if (!format.isInitialized())
      {
        formattingRecords.addStyle(format);
      }
    }
    catch (NumFormatRecordsException e)
    {
      logger.warn("Maximum number of format records exceeded.  Using " +
                  "default format.");
      format = styles.getNormalStyle();
    }
  }

  /**
   * Accessor for the cell features
   *
   * @return the cell features or NULL if this cell doesn't have any
   */
  public CellFeatures getCellFeatures()
  {
    return features;
  }

  /**
   * Accessor for the cell features
   *
   * @return the cell features or NULL if this cell doesn't have any
   */
  public WritableCellFeatures getWritableCellFeatures()
  {
    return features;
  }

  /**
   * Sets the cell features
   *
   * @param cf the cell features
   */
  public void setCellFeatures(WritableCellFeatures cf)
  {
    if (features != null) 
    {
      logger.warn("current cell features not null - overwriting");
    }

    features = cf;
    cf.setWritableCell(this);

    // If the cell is already on the worksheet, then add the cell features
    // to the workbook
    if (referenced)
    {
      addCellFeatures();
    }
  }

  /**
   * Handles any addition cell features, such as comments or data 
   * validation.  Called internally from this class when a cell is 
   * added to the workbook, and also externally from BaseCellFeatures
   * following a call to setComment
   */
  public final void addCellFeatures()
  {
    if (features == null)
    {
      return;
    }

    if (copied == true)
    {
      copied = false;

      /*
      if (features.hasDataValidation())
      {
        DataValidation dv = sheet.getDataValidation();
        DataValiditySettingsRecord dvsr = 
          dv.getDataValiditySettings(column, row);
        features.setValidationSettings(dvsr);
      }
      else
      {
        // For comments, make sure we go the whole nine yards when
        // the comment gets added to the sheet
        copied = false;
      }
      */

      return;
    }

    if (features.getComment() != null)
    {
      Comment comment = new Comment(features.getComment(), 
                                    column, row);
      comment.setWidth(features.getCommentWidth());
      comment.setHeight(features.getCommentHeight());
      sheet.addDrawing(comment);      
      sheet.getWorkbook().addDrawing(comment);
      features.setCommentDrawing(comment);
    }

    if (features.hasDataValidation())
    {
      try
      {
        features.getDVParser().setCell(column, 
                                       row, 
                                       sheet.getWorkbook(), 
                                       sheet.getWorkbook(),
                                       sheet.getWorkbookSettings());
      }
      catch (jxl.biff.formula.FormulaException e)
      {
        e.printStackTrace();
        Assert.verify(false);
      }
      sheet.addValidationCell(this);
      if (!features.hasDropDown())
      {
        return;
      }
      
      // Get the combo box drawing object for list validations
      if (sheet.getComboBox() == null)
      {
        ComboBox cb = new ComboBox();
        sheet.addDrawing(cb);
        sheet.getWorkbook().addDrawing(cb);
        sheet.setComboBox(cb);
      }

      features.setComboBox(sheet.getComboBox());
    }
  }

  /**
   * Called by the cell features to remove a comment
   *
   * @param c the comment to remove
   */
  public final void removeComment(Comment c)
  {
    sheet.removeDrawing(c);
  }

  /**
   * Called when doing a copy of a writable object to indicate the source
   * was writable than a read only copy and certain things (most notably
   * the comments will need to be re-evaluated)
   *
   * @param boolean the copied flag
   */
  final void setCopied(boolean c)
  {
    copied = c;
  }

}

⌨️ 快捷键说明

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