package org.apache.poi.hssf.record.formula;
-import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
+import org.apache.poi.ss.usermodel.ErrorConstants;
import org.apache.poi.util.LittleEndianInput;
import org.apache.poi.util.LittleEndianOutput;
}
public String toFormulaString() {
- return HSSFErrorConstants.getText(HSSFErrorConstants.ERROR_REF);
+ return ErrorConstants.getText(ErrorConstants.ERROR_REF);
}
public byte getDefaultOperandClass() {
package org.apache.poi.hssf.record.formula;
-import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
+import org.apache.poi.ss.usermodel.ErrorConstants;
import org.apache.poi.ss.formula.FormulaRenderingWorkbook;
import org.apache.poi.ss.formula.WorkbookDependentFormula;
import org.apache.poi.util.LittleEndianInput;
}
public String toFormulaString(FormulaRenderingWorkbook book) {
return ExternSheetNameResolver.prependSheetName(book, field_1_index_extern_sheet,
- HSSFErrorConstants.getText(HSSFErrorConstants.ERROR_REF));
+ ErrorConstants.getText(ErrorConstants.ERROR_REF));
}
public String toFormulaString() {
throw new RuntimeException("3D references need a workbook to determine formula text");
package org.apache.poi.hssf.record.formula;
-import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
+import org.apache.poi.ss.usermodel.ErrorConstants;
import org.apache.poi.ss.formula.FormulaRenderingWorkbook;
import org.apache.poi.ss.formula.WorkbookDependentFormula;
import org.apache.poi.util.LittleEndianInput;
public String toFormulaString(FormulaRenderingWorkbook book) {
return ExternSheetNameResolver.prependSheetName(book, field_1_index_extern_sheet,
- HSSFErrorConstants.getText(HSSFErrorConstants.ERROR_REF));
+ ErrorConstants.getText(ErrorConstants.ERROR_REF));
}
public String toFormulaString() {
throw new RuntimeException("3D references need a workbook to determine formula text");
package org.apache.poi.hssf.record.formula;
-import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
+import org.apache.poi.ss.usermodel.ErrorConstants;
import org.apache.poi.util.LittleEndianInput;
import org.apache.poi.util.LittleEndianOutput;
public final class ErrPtg extends ScalarConstantPtg {
// convenient access to namespace
- private static final HSSFErrorConstants EC = null;
+ private static final ErrorConstants EC = null;
/** <b>#NULL!</b> - Intersection of two cell ranges is empty */
public static final ErrPtg NULL_INTERSECTION = new ErrPtg(EC.ERROR_NULL);
/** Creates new ErrPtg */
private ErrPtg(int errorCode) {
- if(!HSSFErrorConstants.isValidCode(errorCode)) {
+ if(!ErrorConstants.isValidCode(errorCode)) {
throw new IllegalArgumentException("Invalid error code (" + errorCode + ")");
}
field_1_error_code = errorCode;
}
public String toFormulaString() {
- return HSSFErrorConstants.getText(field_1_error_code);
+ return ErrorConstants.getText(field_1_error_code);
}
public int getSize() {
public static ErrPtg valueOf(int code) {
switch(code) {
- case HSSFErrorConstants.ERROR_DIV_0: return DIV_ZERO;
- case HSSFErrorConstants.ERROR_NA: return N_A;
- case HSSFErrorConstants.ERROR_NAME: return NAME_INVALID;
- case HSSFErrorConstants.ERROR_NULL: return NULL_INTERSECTION;
- case HSSFErrorConstants.ERROR_NUM: return NUM_ERROR;
- case HSSFErrorConstants.ERROR_REF: return REF_INVALID;
- case HSSFErrorConstants.ERROR_VALUE: return VALUE_INVALID;
+ case ErrorConstants.ERROR_DIV_0: return DIV_ZERO;
+ case ErrorConstants.ERROR_NA: return N_A;
+ case ErrorConstants.ERROR_NAME: return NAME_INVALID;
+ case ErrorConstants.ERROR_NULL: return NULL_INTERSECTION;
+ case ErrorConstants.ERROR_NUM: return NUM_ERROR;
+ case ErrorConstants.ERROR_REF: return REF_INVALID;
+ case ErrorConstants.ERROR_VALUE: return VALUE_INVALID;
}
throw new RuntimeException("Unexpected error code (" + code + ")");
}
package org.apache.poi.hssf.record.formula;
-import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
+import org.apache.poi.ss.usermodel.ErrorConstants;
import org.apache.poi.util.LittleEndianInput;
import org.apache.poi.util.LittleEndianOutput;
}
public String toFormulaString() {
- return HSSFErrorConstants.getText(HSSFErrorConstants.ERROR_REF);
+ return ErrorConstants.getText(ErrorConstants.ERROR_REF);
}
public byte getDefaultOperandClass() {
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
import org.apache.poi.hssf.record.formula.eval.EvaluationException;
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.ss.usermodel.DateUtil;
/**
private static SimpleDate createDate(int dayCount) {
GregorianCalendar calendar = new GregorianCalendar(UTC_TIME_ZONE);
- HSSFDateUtil.setCalendar(calendar, dayCount, 0, false);
+ DateUtil.setCalendar(calendar, dayCount, 0, false);
return new SimpleDate(calendar);
}
package org.apache.poi.hssf.record.formula.eval;
-import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
+import org.apache.poi.ss.usermodel.ErrorConstants;
/**
* @author Amol S. Deshmukh < amolweb at ya hoo dot com >
public final class ErrorEval implements ValueEval {
// convenient access to namespace
- private static final HSSFErrorConstants EC = null;
+ private static final ErrorConstants EC = null;
/** <b>#NULL!</b> - Intersection of two cell ranges is empty */
public static final ErrorEval NULL_INTERSECTION = new ErrorEval(EC.ERROR_NULL);
*/
public static ErrorEval valueOf(int errorCode) {
switch(errorCode) {
- case HSSFErrorConstants.ERROR_NULL: return NULL_INTERSECTION;
- case HSSFErrorConstants.ERROR_DIV_0: return DIV_ZERO;
- case HSSFErrorConstants.ERROR_VALUE: return VALUE_INVALID;
- case HSSFErrorConstants.ERROR_REF: return REF_INVALID;
- case HSSFErrorConstants.ERROR_NAME: return NAME_INVALID;
- case HSSFErrorConstants.ERROR_NUM: return NUM_ERROR;
- case HSSFErrorConstants.ERROR_NA: return NA;
+ case ErrorConstants.ERROR_NULL: return NULL_INTERSECTION;
+ case ErrorConstants.ERROR_DIV_0: return DIV_ZERO;
+ case ErrorConstants.ERROR_VALUE: return VALUE_INVALID;
+ case ErrorConstants.ERROR_REF: return REF_INVALID;
+ case ErrorConstants.ERROR_NAME: return NAME_INVALID;
+ case ErrorConstants.ERROR_NUM: return NUM_ERROR;
+ case ErrorConstants.ERROR_NA: return NA;
// non-std errors (conditions modeled as errors by POI)
case CIRCULAR_REF_ERROR_CODE: return CIRCULAR_REF_ERROR;
}
* @return the String representation of the specified Excel error code.
*/
public static String getText(int errorCode) {
- if(HSSFErrorConstants.isValidCode(errorCode)) {
- return HSSFErrorConstants.getText(errorCode);
+ if(ErrorConstants.isValidCode(errorCode)) {
+ return ErrorConstants.getText(errorCode);
}
// It is desirable to make these (arbitrary) strings look clearly different from any other
// value expression that might appear in a formula. In addition these error strings should
cells this method could not detect it.
Logic to detect evaluation cycles of all kinds has been coded in EvaluationCycleDetector
- (and HSSFFormulaEvaluator).
+ (and FormulaEvaluator).
*/
}
* RefEval is the super interface for Ref2D and Ref3DEval. Basically a RefEval
* impl should contain reference to the original ReferencePtg or Ref3DPtg as
* well as the final "value" resulting from the evaluation of the cell
- * reference. Thus if the HSSFCell has type CELL_TYPE_NUMERIC, the contained
+ * reference. Thus if the Cell has type CELL_TYPE_NUMERIC, the contained
* value object should be of type NumberEval; if cell type is CELL_TYPE_STRING,
* contained value object should be of type StringEval
*/
import org.apache.poi.hssf.record.formula.eval.NumberEval;
import org.apache.poi.hssf.record.formula.eval.OperandResolver;
import org.apache.poi.hssf.record.formula.eval.ValueEval;
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.ss.usermodel.DateUtil;
/**
* Implementation of Excel functions DAY, MONTH and YEAR
}
throw new IllegalStateException("bad date field " + _dateFieldId);
}
- Date d = HSSFDateUtil.getJavaDate(serialDay, false); // TODO fix 1900/1904 problem
+ Date d = DateUtil.getJavaDate(serialDay, false); // TODO fix 1900/1904 problem
Calendar c = new GregorianCalendar();
c.setTime(d);
import org.apache.poi.hssf.record.formula.eval.EvaluationException;
import org.apache.poi.hssf.record.formula.eval.NumberEval;
import org.apache.poi.hssf.record.formula.eval.ValueEval;
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.ss.usermodel.DateUtil;
/**
c.set(year, month, day, 0, 0, 0);
c.set(Calendar.MILLISECOND, 0);
- return HSSFDateUtil.getExcelDate(c.getTime(), false); // TODO - fix 1900/1904 problem
+ return DateUtil.getExcelDate(c.getTime(), false); // TODO - fix 1900/1904 problem
}
private static int getYear(double d) {
import org.apache.poi.hssf.record.formula.eval.NumberEval;
import org.apache.poi.hssf.record.formula.eval.OperandResolver;
import org.apache.poi.hssf.record.formula.eval.ValueEval;
-import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
+import org.apache.poi.ss.usermodel.ErrorConstants;
/**
* Implementation for the ERROR.TYPE() Excel function.
* </table>
*
* Note - the results of ERROR.TYPE() are different to the constants defined in
- * <tt>HSSFErrorConstants</tt>.
+ * <tt>ErrorConstants</tt>.
* </p>
*
* @author Josh Micich
private int translateErrorCodeToErrorTypeValue(int errorCode) {
switch (errorCode) {
- case HSSFErrorConstants.ERROR_NULL: return 1;
- case HSSFErrorConstants.ERROR_DIV_0: return 2;
- case HSSFErrorConstants.ERROR_VALUE: return 3;
- case HSSFErrorConstants.ERROR_REF: return 4;
- case HSSFErrorConstants.ERROR_NAME: return 5;
- case HSSFErrorConstants.ERROR_NUM: return 6;
- case HSSFErrorConstants.ERROR_NA : return 7;
+ case ErrorConstants.ERROR_NULL: return 1;
+ case ErrorConstants.ERROR_DIV_0: return 2;
+ case ErrorConstants.ERROR_VALUE: return 3;
+ case ErrorConstants.ERROR_REF: return 4;
+ case ErrorConstants.ERROR_NAME: return 5;
+ case ErrorConstants.ERROR_NUM: return 6;
+ case ErrorConstants.ERROR_NA : return 7;
}
throw new IllegalArgumentException("Invalid error code (" + errorCode + ")");
}
import org.apache.poi.hssf.record.formula.eval.NumberEval;
import org.apache.poi.hssf.record.formula.eval.ValueEval;
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.ss.usermodel.DateUtil;
/**
* Implementation of Excel NOW() Function
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex) {
Date now = new Date(System.currentTimeMillis());
- return new NumberEval(HSSFDateUtil.getExcelDate(now));
+ return new NumberEval(DateUtil.getExcelDate(now));
}
}
import org.apache.poi.hssf.record.formula.eval.NumberEval;
import org.apache.poi.hssf.record.formula.eval.ValueEval;
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.ss.usermodel.DateUtil;
/**
* Implementation of Excel TODAY() Function<br/>
Calendar now = new GregorianCalendar();
now.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DATE),0,0,0);
now.set(Calendar.MILLISECOND, 0);
- return new NumberEval(HSSFDateUtil.getExcelDate(now.getTime()));
+ return new NumberEval(DateUtil.getExcelDate(now.getTime()));
}
}
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
-import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Row;
Row row = sheet.createRow(0);
bottomValueCell = row.createCell(0);
topValueCell = row.createCell(1);
- formulaCell = row.createCell(2, HSSFCell.CELL_TYPE_FORMULA);
+ formulaCell = row.createCell(2, Cell.CELL_TYPE_FORMULA);
}
@Override
import junit.framework.TestCase;
import org.apache.poi.hssf.record.formula.eval.EvaluationException;
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.ss.usermodel.DateUtil;
/**
* Specific test cases for YearFracCalculator
c.set(year, month-1, day, 0, 0, 0);
c.set(Calendar.MILLISECOND, 0);
- return HSSFDateUtil.getExcelDate(c.getTime());
+ return DateUtil.getExcelDate(c.getTime());
}
}