add HSSFCell.setCachedErrorResult(FormulaError)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748174 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ef3564968a
commit
e61e346436
@ -81,14 +81,25 @@ public final class BoolErrRecord extends CellRecord implements Cloneable {
|
||||
}
|
||||
|
||||
/**
|
||||
* set the error value for the cell
|
||||
* set the error value for the cell. See {@link FormulaError} for valid codes.
|
||||
*
|
||||
* @param value error representing the error value
|
||||
* this value can only be 0,7,15,23,29,36 or 42
|
||||
* see bugzilla bug 16560 for an explanation
|
||||
*/
|
||||
public void setValue(byte value) {
|
||||
switch(FormulaError.forInt(value)) {
|
||||
setValue(FormulaError.forInt(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* set the error value for the cell
|
||||
*
|
||||
* @param value error representing the error value
|
||||
* this value can only be 0,7,15,23,29,36 or 42
|
||||
* see bugzilla bug 16560 for an explanation
|
||||
*/
|
||||
public void setValue(FormulaError value) {
|
||||
switch(value) {
|
||||
case NULL:
|
||||
case DIV0:
|
||||
case VALUE:
|
||||
@ -96,11 +107,11 @@ public final class BoolErrRecord extends CellRecord implements Cloneable {
|
||||
case NAME:
|
||||
case NUM:
|
||||
case NA:
|
||||
_value = value;
|
||||
_value = value.getCode();
|
||||
_isError = true;
|
||||
return;
|
||||
default:
|
||||
throw new IllegalArgumentException("Error Value can only be 0,7,15,23,29,36 or 42. It cannot be "+value);
|
||||
throw new IllegalArgumentException("Error Value can only be 0,7,15,23,29,36 or 42. It cannot be "+value.getCode()+" ("+value+")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,13 @@ import org.apache.poi.hssf.record.Record;
|
||||
import org.apache.poi.hssf.record.RecordFormatException;
|
||||
import org.apache.poi.hssf.record.SharedFormulaRecord;
|
||||
import org.apache.poi.hssf.record.StringRecord;
|
||||
import org.apache.poi.hssf.util.CellRangeAddress8Bit;
|
||||
import org.apache.poi.ss.formula.ptg.ExpPtg;
|
||||
import org.apache.poi.ss.formula.ptg.Ptg;
|
||||
import org.apache.poi.hssf.util.CellRangeAddress8Bit;
|
||||
import org.apache.poi.ss.util.CellReference;
|
||||
import org.apache.poi.ss.formula.Formula;
|
||||
import org.apache.poi.ss.usermodel.FormulaError;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.CellReference;
|
||||
|
||||
/**
|
||||
* The formula record aggregate is used to join together the formula record and it's
|
||||
@ -180,6 +181,9 @@ public final class FormulaRecordAggregate extends RecordAggregate implements Cel
|
||||
_stringRecord = null;
|
||||
_formulaRecord.setCachedResultErrorCode(errorCode);
|
||||
}
|
||||
public void setCachedErrorResult(FormulaError error) {
|
||||
setCachedErrorResult(error.getCode());
|
||||
}
|
||||
public void setCachedDoubleResult(double value) {
|
||||
_stringRecord = null;
|
||||
_formulaRecord.setValue(value);
|
||||
|
@ -791,16 +791,15 @@ public class HSSFCell implements Cell {
|
||||
int row=_record.getRow();
|
||||
short col=_record.getColumn();
|
||||
short styleIndex=_record.getXFIndex();
|
||||
byte code = error.getCode();
|
||||
switch (_cellType) {
|
||||
default:
|
||||
setCellType(CELL_TYPE_ERROR, false, row, col, styleIndex);
|
||||
// fall through
|
||||
case CELL_TYPE_ERROR:
|
||||
(( BoolErrRecord ) _record).setValue(code);
|
||||
(( BoolErrRecord ) _record).setValue(error);
|
||||
break;
|
||||
case CELL_TYPE_FORMULA:
|
||||
((FormulaRecordAggregate)_record).setCachedErrorResult(code);
|
||||
((FormulaRecordAggregate)_record).setCachedErrorResult(error.getCode());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user