Abstract class which stores the common data used for cells, such
as row, column and formatting information.
Any record which directly represents the contents of a cell, such
as labels and numbers, are derived from this class
data store
| Constructor: |
protected CellValue(Type t,
Cell c) {
this(t, c.getColumn(), c.getRow());
copied = true;
format = (XFRecord) c.getCellFormat();
if (c.getCellFeatures() != null)
{
features = new WritableCellFeatures(c.getCellFeatures());
features.setWritableCell(this);
}
}
Constructor used when creating a writable cell from a read-only cell
(when copying a workbook) Parameters:
c - the cell to clone
t - the type of this cell
|
protected CellValue(Type t,
int c,
int r) {
this(t, c, r, WritableWorkbook.NORMAL_STYLE);
copied = false;
}
Constructor used when building writable cells from the Java API Parameters:
c - the column
t - the type indicator
r - the row
|
protected CellValue(Type t,
int c,
int r,
CellFormat st) {
super(t);
row = r;
column = c;
format = (XFRecord) st;
referenced = false;
copied = false;
}
Overloaded constructor used when building writable cells from the
Java API which also takes a format Parameters:
c - the column
t - the cell type
r - the row
st - the format to apply to this cell
|
protected CellValue(Type t,
int c,
int r,
CellValue cv) {
super(t);
row = r;
column = c;
format = cv.format;
referenced = false;
copied = false; // used during a deep copy, so the cell features need
// to be added again
if (cv.features != null)
{
features = new WritableCellFeatures(cv.features);
features.setWritableCell(this);
}
}
Parameters:
c - the column
t - the cell type
r - the row
cv - the value to copy
|
| Method from jxl.write.biff.CellValue Detail: |
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());
}
}
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 |
void columnInserted(Sheet s,
int sheetIndex,
int col) {
}
Called when a column is inserted on the specified sheet. Notifies all
RCIR cells of this change. The default implementation here does nothing |
void columnRemoved(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 |
void decrementColumn() {
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 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");
}
}
}
Decrements the row of this cell by one. Invoked by the sheet when
removing rows |
public CellFeatures getCellFeatures() {
return features;
}
Accessor for the cell features |
public CellFormat getCellFormat() {
return format;
}
API method which gets the format applied to this cell |
public int getColumn() {
return column;
}
Returns the column number of this cell |
public byte[] getData() {
byte[] mydata = new byte[6];
IntegerHelper.getTwoBytes(row, mydata, 0);
IntegerHelper.getTwoBytes(column, mydata, 2);
IntegerHelper.getTwoBytes(format.getXFIndex(), mydata, 4);
return mydata;
}
Gets the data to write to the output file |
public int getRow() {
return row;
}
Returns the row number of this cell |
protected WritableSheetImpl getSheet() {
return sheet;
}
Accessor for the sheet containing this cell |
public WritableCellFeatures getWritableCellFeatures() {
return features;
}
Accessor for the cell features |
final int getXFIndex() {
return format.getXFIndex();
}
Gets the internal index of the formatting record |
void incrementColumn() {
column++;
if (features != null)
{
Comment c = features.getCommentDrawing();
if (c != null)
{
c.setX(column);
c.setY(row);
}
}
}
Increments the column of this cell by one. Invoked by the sheet when
inserting columns |
void incrementRow() {
row++;
if (features != null)
{
Comment c = features.getCommentDrawing();
if (c != null)
{
c.setX(column);
c.setY(row);
}
}
}
Increments the row of this cell by one. Invoked by the sheet when
inserting rows |
public boolean isHidden() {
ColumnInfoRecord cir = sheet.getColumnInfo(column);
if (cir != null && cir.getWidth() == 0)
{
return true;
}
RowRecord rr = sheet.getRowInfo(row);
if (rr != null && (rr.getRowHeight() == 0 || rr.isCollapsed()))
{
return true;
}
return false;
}
Indicates whether or not this cell is hidden, by virtue of either
the entire row or column being collapsed |
final boolean isReferenced() {
return referenced;
}
Internal method to see if this cell is referenced within the workbook.
Once this has been placed in the workbook, it becomes immutable |
public final void removeCellFeatures() {
if (features == null)
{
return;
}
// Remove the comment
features.removeComment();
// Remove the data validation
features.removeDataValidation();
}
Removes the cell features from the Workbook/Worksheet. Called when
a cell is being removed/replaced from a worksheet |
public final void removeComment(Comment c) {
sheet.removeDrawing(c);
}
Called by the cell features to remove a comment |
public final void removeDataValidation() {
sheet.removeDataValidation(this);
}
Called by the cell features to remove the data validation |
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 |
void rowRemoved(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 |
void setCellDetails(FormattingRecords fr,
SharedStrings ss,
WritableSheetImpl s) {
referenced = true;
sheet = s;
formattingRecords = fr;
addCellFormat();
addCellFeatures();
}
Called when the cell is added to the worksheet in order to indicate
that this object is already added to the worksheet
This method also verifies that the associated formats and formats
have been initialized correctly |
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();
}
}
|
public void setCellFormat(CellFormat cf) {
format = (XFRecord) cf;
// If the referenced flag has not been set, this cell has not
// been added to the spreadsheet, so we don't need to perform
// any further logic
if (!referenced)
{
return;
}
// The cell has already been added to the spreadsheet, so the
// formattingRecords reference must be initialized
Assert.verify(formattingRecords != null);
addCellFormat();
}
An API function which sets the format to apply to this cell |
final void setCopied(boolean c) {
copied = 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) |