bug 59791: getCellType and getCachedFormulaResultType should return an integer for backwards compatibility
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751256 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fba65665fb
commit
034d3cfcca
@ -185,7 +185,7 @@ public final class HSSFReadWrite {
|
||||
HSSFCell cell = row.getCell(c);
|
||||
String value = null;
|
||||
|
||||
switch (cell.getCellType()) {
|
||||
switch (cell.getCellTypeEnum()) {
|
||||
|
||||
case FORMULA:
|
||||
value = "FORMULA value=" + cell.getCellFormula();
|
||||
|
@ -142,7 +142,7 @@ public class SVSheetTable extends JTable {
|
||||
HSSFCell cell = (HSSFCell) getValueAt(row, col);
|
||||
String formula = "";
|
||||
if (cell != null) {
|
||||
if (cell.getCellType() == CellType.FORMULA) {
|
||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
formula = cell.getCellFormula();
|
||||
} else {
|
||||
formula = cell.toString();
|
||||
|
@ -151,7 +151,7 @@ public class SVTableCellEditor extends AbstractCellEditor implements TableCellEd
|
||||
|
||||
|
||||
//Set the value that is rendered for the cell
|
||||
switch (cell.getCellType()) {
|
||||
switch (cell.getCellTypeEnum()) {
|
||||
case BLANK:
|
||||
editor.setText("");
|
||||
break;
|
||||
|
@ -165,7 +165,7 @@ public class SVTableCellRenderer extends JLabel
|
||||
isBorderSet=true;
|
||||
|
||||
//Set the value that is rendered for the cell
|
||||
switch (c.getCellType()) {
|
||||
switch (c.getCellTypeEnum()) {
|
||||
case BLANK:
|
||||
setValue("");
|
||||
break;
|
||||
|
@ -179,7 +179,7 @@ public class ExcelComparator {
|
||||
|
||||
private void compareDataInCell(Locator loc1, Locator loc2) {
|
||||
if (isCellTypeMatches(loc1, loc2)) {
|
||||
final CellType loc1cellType = loc1.cell.getCellType();
|
||||
final CellType loc1cellType = loc1.cell.getCellTypeEnum();
|
||||
switch(loc1cellType) {
|
||||
case BLANK:
|
||||
case STRING:
|
||||
@ -581,8 +581,8 @@ public class ExcelComparator {
|
||||
* Checks if cell type matches.
|
||||
*/
|
||||
private boolean isCellTypeMatches(Locator loc1, Locator loc2) {
|
||||
CellType type1 = loc1.cell.getCellType();
|
||||
CellType type2 = loc2.cell.getCellType();
|
||||
CellType type1 = loc1.cell.getCellTypeEnum();
|
||||
CellType type2 = loc2.cell.getCellTypeEnum();
|
||||
if (type1 == type2) return true;
|
||||
addMessage(loc1, loc2,
|
||||
"Cell Data-Type does not Match in :: ",
|
||||
|
@ -542,7 +542,7 @@ public class ToCSV {
|
||||
csvLine.add("");
|
||||
}
|
||||
else {
|
||||
if(cell.getCellType() != CellType.FORMULA) {
|
||||
if(cell.getCellTypeEnum() != CellType.FORMULA) {
|
||||
csvLine.add(this.formatter.formatCellValue(cell));
|
||||
}
|
||||
else {
|
||||
|
@ -336,9 +336,9 @@ public class ToHtml {
|
||||
}
|
||||
|
||||
private static CellType ultimateCellType(Cell c) {
|
||||
CellType type = c.getCellType();
|
||||
CellType type = c.getCellTypeEnum();
|
||||
if (type == CellType.FORMULA)
|
||||
type = c.getCachedFormulaResultType();
|
||||
type = c.getCachedFormulaResultTypeEnum();
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
|
||||
// Only output if requested
|
||||
outputContents = _includeBlankCells;
|
||||
} else {
|
||||
switch(cell.getCellType()) {
|
||||
switch(cell.getCellTypeEnum()) {
|
||||
case STRING:
|
||||
text.append(cell.getRichStringCellValue().getString());
|
||||
break;
|
||||
@ -338,7 +338,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
|
||||
if(!_shouldEvaluateFormulas) {
|
||||
text.append(cell.getCellFormula());
|
||||
} else {
|
||||
switch(cell.getCachedFormulaResultType()) {
|
||||
switch(cell.getCachedFormulaResultTypeEnum()) {
|
||||
case STRING:
|
||||
HSSFRichTextString str = cell.getRichStringCellValue();
|
||||
if(str != null && str.length() > 0) {
|
||||
@ -359,13 +359,13 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
|
||||
text.append(ErrorEval.getText(cell.getErrorCellValue()));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected cell cached formula result type: " + cell.getCachedFormulaResultType());
|
||||
throw new IllegalStateException("Unexpected cell cached formula result type: " + cell.getCachedFormulaResultTypeEnum());
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unexpected cell type (" + cell.getCellType() + ")");
|
||||
throw new RuntimeException("Unexpected cell type (" + cell.getCellTypeEnum() + ")");
|
||||
}
|
||||
|
||||
// Output the comment, if requested and exists
|
||||
|
@ -53,6 +53,7 @@ import org.apache.poi.ss.util.CellAddress;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.CellReference;
|
||||
import org.apache.poi.ss.util.NumberToTextConverter;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.LocaleUtil;
|
||||
|
||||
/**
|
||||
@ -442,9 +443,23 @@ public class HSSFCell implements Cell {
|
||||
|
||||
/**
|
||||
* get the cells type (numeric, formula or string)
|
||||
*
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*/
|
||||
@Override
|
||||
public CellType getCellType()
|
||||
public int getCellType()
|
||||
{
|
||||
return getCellTypeEnum().getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the cells type (numeric, formula or string)
|
||||
* @deprecated POI 3.15 beta 3
|
||||
*/
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCellTypeEnum()
|
||||
{
|
||||
return _cellType;
|
||||
}
|
||||
@ -995,7 +1010,7 @@ public class HSSFCell implements Cell {
|
||||
* Errors are displayed as #ERR<errIdx>
|
||||
*/
|
||||
public String toString() {
|
||||
switch (getCellType()) {
|
||||
switch (getCellTypeEnum()) {
|
||||
case BLANK:
|
||||
return "";
|
||||
case BOOLEAN:
|
||||
@ -1015,7 +1030,7 @@ public class HSSFCell implements Cell {
|
||||
case STRING:
|
||||
return getStringCellValue();
|
||||
default:
|
||||
return "Unknown Cell Type: " + getCellType();
|
||||
return "Unknown Cell Type: " + getCellTypeEnum();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1130,11 +1145,29 @@ public class HSSFCell implements Cell {
|
||||
|
||||
/**
|
||||
* Only valid for formula cells
|
||||
*
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||
* on the cached value of the formula
|
||||
*/
|
||||
public CellType getCachedFormulaResultType() {
|
||||
@Override
|
||||
public int getCachedFormulaResultType() {
|
||||
return getCachedFormulaResultTypeEnum().getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Only valid for formula cells
|
||||
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||
* on the cached value of the formula
|
||||
* @deprecated POI 3.15 beta 3
|
||||
*/
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCachedFormulaResultTypeEnum() {
|
||||
if (_cellType != CellType.FORMULA) {
|
||||
throw new IllegalStateException("Only formula cells have cached results");
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ package org.apache.poi.hssf.usermodel;
|
||||
import org.apache.poi.ss.formula.EvaluationCell;
|
||||
import org.apache.poi.ss.formula.EvaluationSheet;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.util.Internal;
|
||||
/**
|
||||
* HSSF wrapper for a cell under evaluation
|
||||
*/
|
||||
@ -49,10 +50,22 @@ final class HSSFEvaluationCell implements EvaluationCell {
|
||||
public boolean getBooleanCellValue() {
|
||||
return _cell.getBooleanCellValue();
|
||||
}
|
||||
/**
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return cell type
|
||||
*/
|
||||
@Override
|
||||
public CellType getCellType() {
|
||||
public int getCellType() {
|
||||
return _cell.getCellType();
|
||||
}
|
||||
/** @deprecated POI 3.15 beta 3 */
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCellTypeEnum() {
|
||||
return _cell.getCellTypeEnum();
|
||||
}
|
||||
@Override
|
||||
public int getColumnIndex() {
|
||||
return _cell.getColumnIndex();
|
||||
@ -76,9 +89,21 @@ final class HSSFEvaluationCell implements EvaluationCell {
|
||||
@Override
|
||||
public String getStringCellValue() {
|
||||
return _cell.getRichStringCellValue().getString();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return cell type of cached formula result
|
||||
*/
|
||||
@Override
|
||||
public CellType getCachedFormulaResultType() {
|
||||
return _cell.getCachedFormulaResultType();
|
||||
public int getCachedFormulaResultType() {
|
||||
return _cell.getCachedFormulaResultType();
|
||||
}
|
||||
/** @deprecated POI 3.15 beta 3 */
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCachedFormulaResultTypeEnum() {
|
||||
return _cell.getCachedFormulaResultTypeEnum();
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (cell.getCellType()) {
|
||||
switch (cell.getCellTypeEnum()) {
|
||||
case BOOLEAN:
|
||||
return CellValue.valueOf(cell.getBooleanCellValue());
|
||||
case ERROR:
|
||||
@ -191,7 +191,7 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
|
||||
case BLANK:
|
||||
return null;
|
||||
default:
|
||||
throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
|
||||
throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")");
|
||||
}
|
||||
|
||||
}
|
||||
@ -214,7 +214,7 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
|
||||
*/
|
||||
@Override
|
||||
public CellType evaluateFormulaCell(Cell cell) {
|
||||
if (cell == null || cell.getCellType() != CellType.FORMULA) {
|
||||
if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
|
||||
return CellType._UNINITIALIZED;
|
||||
}
|
||||
CellValue cv = evaluateFormulaCellValue(cell);
|
||||
@ -244,7 +244,7 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
|
||||
return null;
|
||||
}
|
||||
HSSFCell result = (HSSFCell) cell;
|
||||
if (cell.getCellType() == CellType.FORMULA) {
|
||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
CellValue cv = evaluateFormulaCellValue(cell);
|
||||
setCellValue(cell, cv);
|
||||
setCellType(cell, cv); // cell will no longer be a formula cell
|
||||
@ -330,7 +330,7 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
|
||||
|
||||
for(Row r : sheet) {
|
||||
for (Cell c : r) {
|
||||
if (c.getCellType() == CellType.FORMULA) {
|
||||
if (c.getCellTypeEnum() == CellType.FORMULA) {
|
||||
evaluator.evaluateFormulaCell(c);
|
||||
}
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ public class HSSFOptimiser {
|
||||
HSSFSheet s = workbook.getSheetAt(sheetNum);
|
||||
for (Row row : s) {
|
||||
for (Cell cell : row) {
|
||||
if(cell.getCellType() == CellType.STRING) {
|
||||
if(cell.getCellTypeEnum() == CellType.STRING) {
|
||||
HSSFRichTextString rtr = (HSSFRichTextString)cell.getRichStringCellValue();
|
||||
UnicodeString u = rtr.getRawUnicodeString();
|
||||
|
||||
|
@ -388,7 +388,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
|
||||
case RETURN_NULL_AND_BLANK:
|
||||
return cell;
|
||||
case RETURN_BLANK_AS_NULL:
|
||||
boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK);
|
||||
boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK);
|
||||
return (isBlank) ? null : cell;
|
||||
case CREATE_NULL_AS_BLANK:
|
||||
return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;
|
||||
|
@ -411,17 +411,17 @@ public class CellFormat {
|
||||
/**
|
||||
* Returns the ultimate cell type, following the results of formulas. If
|
||||
* the cell is a {@link CellType#FORMULA}, this returns the result of
|
||||
* {@link Cell#getCachedFormulaResultType()}. Otherwise this returns the
|
||||
* result of {@link Cell#getCellType()}.
|
||||
* {@link Cell#getCachedFormulaResultTypeEnum()}. Otherwise this returns the
|
||||
* result of {@link Cell#getCellTypeEnum()}.
|
||||
*
|
||||
* @param cell The cell.
|
||||
*
|
||||
* @return The ultimate type of this cell.
|
||||
*/
|
||||
public static CellType ultimateType(Cell cell) {
|
||||
CellType type = cell.getCellType();
|
||||
CellType type = cell.getCellTypeEnum();
|
||||
if (type == CellType.FORMULA)
|
||||
return cell.getCachedFormulaResultType();
|
||||
return cell.getCachedFormulaResultTypeEnum();
|
||||
else
|
||||
return type;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ final class EvaluationCache {
|
||||
Loc loc = new Loc(bookIndex, sheetIndex, rowIndex, columnIndex);
|
||||
PlainValueCellCacheEntry pcce = _plainCellCache.get(loc);
|
||||
|
||||
if (cell.getCellType() == CellType.FORMULA) {
|
||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
if (fcce == null) {
|
||||
fcce = new FormulaCellCacheEntry();
|
||||
if (pcce == null) {
|
||||
@ -197,7 +197,7 @@ final class EvaluationCache {
|
||||
}
|
||||
public void notifyDeleteCell(int bookIndex, int sheetIndex, EvaluationCell cell) {
|
||||
|
||||
if (cell.getCellType() == CellType.FORMULA) {
|
||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
FormulaCellCacheEntry fcce = _formulaCellCache.remove(cell);
|
||||
if (fcce == null) {
|
||||
// formula cell has not been evaluated yet
|
||||
|
@ -30,19 +30,35 @@ import org.apache.poi.ss.usermodel.CellType;
|
||||
public interface EvaluationCell {
|
||||
/**
|
||||
* @return an Object that identifies the underlying cell,
|
||||
* suitable for use as a key in a {@link java.util.HashMap}
|
||||
* suitable for use as a key in a {@link java.util.HashMap}
|
||||
*/
|
||||
Object getIdentityKey();
|
||||
|
||||
EvaluationSheet getSheet();
|
||||
int getRowIndex();
|
||||
int getColumnIndex();
|
||||
CellType getCellType();
|
||||
/**
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return cell type
|
||||
*/
|
||||
int getCellType();
|
||||
/** @deprecated POI 3.15 beta 3 */
|
||||
CellType getCellTypeEnum();
|
||||
|
||||
double getNumericCellValue();
|
||||
String getStringCellValue();
|
||||
boolean getBooleanCellValue();
|
||||
int getErrorCellValue();
|
||||
|
||||
CellType getCachedFormulaResultType();
|
||||
|
||||
/**
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return cell type of cached formula result
|
||||
*/
|
||||
int getCachedFormulaResultType();
|
||||
/** @deprecated POI 3.15 beta 3 */
|
||||
CellType getCachedFormulaResultTypeEnum();
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ final class SheetRefEvaluator {
|
||||
public boolean isSubTotal(int rowIndex, int columnIndex){
|
||||
boolean subtotal = false;
|
||||
EvaluationCell cell = getSheet().getCell(rowIndex, columnIndex);
|
||||
if(cell != null && cell.getCellType() == CellType.FORMULA){
|
||||
if(cell != null && cell.getCellTypeEnum() == CellType.FORMULA){
|
||||
EvaluationWorkbook wb = _bookEvaluator.getWorkbook();
|
||||
for(Ptg ptg : wb.getFormulaTokens(cell)){
|
||||
if(ptg instanceof FuncVarPtg){
|
||||
|
@ -276,7 +276,7 @@ public final class WorkbookEvaluator {
|
||||
// avoid tracking dependencies to cells that have constant definition
|
||||
boolean shouldCellDependencyBeRecorded = _stabilityClassifier == null ? true
|
||||
: !_stabilityClassifier.isCellFinal(sheetIndex, rowIndex, columnIndex);
|
||||
if (srcCell == null || srcCell.getCellType() != CellType.FORMULA) {
|
||||
if (srcCell == null || srcCell.getCellTypeEnum() != CellType.FORMULA) {
|
||||
ValueEval result = getValueFromNonFormulaCell(srcCell);
|
||||
if (shouldCellDependencyBeRecorded) {
|
||||
tracker.acceptPlainValueDependency(_workbookIx, sheetIndex, rowIndex, columnIndex, result);
|
||||
@ -314,7 +314,7 @@ public final class WorkbookEvaluator {
|
||||
} catch (RuntimeException re) {
|
||||
if (re.getCause() instanceof WorkbookNotFoundException && _ignoreMissingWorkbooks) {
|
||||
logInfo(re.getCause().getMessage() + " - Continuing with cached value!");
|
||||
switch(srcCell.getCachedFormulaResultType()) {
|
||||
switch(srcCell.getCachedFormulaResultTypeEnum()) {
|
||||
case NUMERIC:
|
||||
result = new NumberEval(srcCell.getNumericCellValue());
|
||||
break;
|
||||
@ -332,7 +332,7 @@ public final class WorkbookEvaluator {
|
||||
break;
|
||||
case FORMULA:
|
||||
default:
|
||||
throw new RuntimeException("Unexpected cell type '" + srcCell.getCellType()+"' found!");
|
||||
throw new RuntimeException("Unexpected cell type '" + srcCell.getCellTypeEnum()+"' found!");
|
||||
}
|
||||
} else {
|
||||
throw re;
|
||||
@ -385,7 +385,7 @@ public final class WorkbookEvaluator {
|
||||
if (cell == null) {
|
||||
return BlankEval.instance;
|
||||
}
|
||||
CellType cellType = cell.getCellType();
|
||||
CellType cellType = cell.getCellTypeEnum();
|
||||
switch (cellType) {
|
||||
case NUMERIC:
|
||||
return new NumberEval(cell.getNumericCellValue());
|
||||
|
@ -17,16 +17,17 @@
|
||||
|
||||
package org.apache.poi.ss.formula.eval.forked;
|
||||
|
||||
import org.apache.poi.ss.formula.EvaluationCell;
|
||||
import org.apache.poi.ss.formula.EvaluationSheet;
|
||||
import org.apache.poi.ss.formula.eval.BlankEval;
|
||||
import org.apache.poi.ss.formula.eval.BoolEval;
|
||||
import org.apache.poi.ss.formula.eval.ErrorEval;
|
||||
import org.apache.poi.ss.formula.eval.NumberEval;
|
||||
import org.apache.poi.ss.formula.eval.StringEval;
|
||||
import org.apache.poi.ss.formula.eval.ValueEval;
|
||||
import org.apache.poi.ss.formula.EvaluationCell;
|
||||
import org.apache.poi.ss.formula.EvaluationSheet;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.util.Internal;
|
||||
|
||||
/**
|
||||
* Represents a cell being used for forked evaluation that has had a value set different from the
|
||||
@ -52,6 +53,7 @@ final class ForkedEvaluationCell implements EvaluationCell {
|
||||
setValue(BlankEval.instance); // followed by a proper call to setValue()
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getIdentityKey() {
|
||||
return _masterCell.getIdentityKey();
|
||||
}
|
||||
@ -101,36 +103,69 @@ final class ForkedEvaluationCell implements EvaluationCell {
|
||||
throw new RuntimeException("Wrong data type (" + _cellType + ")");
|
||||
}
|
||||
}
|
||||
public CellType getCellType() {
|
||||
/**
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return cell type
|
||||
*/
|
||||
@Override
|
||||
public int getCellType() {
|
||||
return _cellType.getCode();
|
||||
}
|
||||
/** @deprecated POI 3.15 beta 3 */
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCellTypeEnum() {
|
||||
return _cellType;
|
||||
}
|
||||
@Override
|
||||
public boolean getBooleanCellValue() {
|
||||
checkCellType(CellType.BOOLEAN);
|
||||
return _booleanValue;
|
||||
}
|
||||
@Override
|
||||
public int getErrorCellValue() {
|
||||
checkCellType(CellType.ERROR);
|
||||
return _errorValue;
|
||||
}
|
||||
@Override
|
||||
public double getNumericCellValue() {
|
||||
checkCellType(CellType.NUMERIC);
|
||||
return _numberValue;
|
||||
}
|
||||
@Override
|
||||
public String getStringCellValue() {
|
||||
checkCellType(CellType.STRING);
|
||||
return _stringValue;
|
||||
}
|
||||
@Override
|
||||
public EvaluationSheet getSheet() {
|
||||
return _sheet;
|
||||
}
|
||||
@Override
|
||||
public int getRowIndex() {
|
||||
return _masterCell.getRowIndex();
|
||||
}
|
||||
@Override
|
||||
public int getColumnIndex() {
|
||||
return _masterCell.getColumnIndex();
|
||||
}
|
||||
public CellType getCachedFormulaResultType() {
|
||||
return _masterCell.getCachedFormulaResultType();
|
||||
}
|
||||
/**
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return cell type of cached formula result
|
||||
*/
|
||||
@Override
|
||||
public int getCachedFormulaResultType() {
|
||||
return _masterCell.getCachedFormulaResultType();
|
||||
}
|
||||
/** @deprecated POI 3.15 beta 3. */
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCachedFormulaResultTypeEnum() {
|
||||
return _masterCell.getCachedFormulaResultTypeEnum();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public final class ForkedEvaluator {
|
||||
public ValueEval evaluate(String sheetName, int rowIndex, int columnIndex) {
|
||||
EvaluationCell cell = _sewb.getEvaluationCell(sheetName, rowIndex, columnIndex);
|
||||
|
||||
switch (cell.getCellType()) {
|
||||
switch (cell.getCellTypeEnum()) {
|
||||
case BOOLEAN:
|
||||
return BoolEval.valueOf(cell.getBooleanCellValue());
|
||||
case ERROR:
|
||||
@ -126,7 +126,7 @@ public final class ForkedEvaluator {
|
||||
case BLANK:
|
||||
return null;
|
||||
default:
|
||||
throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
|
||||
throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")");
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -23,6 +23,7 @@ import java.util.Date;
|
||||
import org.apache.poi.ss.formula.FormulaParseException;
|
||||
import org.apache.poi.ss.util.CellAddress;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.util.Internal;
|
||||
|
||||
/**
|
||||
* High level representation of a cell in a row of a spreadsheet.
|
||||
@ -153,18 +154,44 @@ public interface Cell {
|
||||
|
||||
/**
|
||||
* Return the cell type.
|
||||
*
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return the cell type
|
||||
*/
|
||||
CellType getCellType();
|
||||
int getCellType();
|
||||
|
||||
/**
|
||||
* Return the cell type.
|
||||
*
|
||||
* @return the cell type
|
||||
* @deprecated POI 3.15 beta 3
|
||||
*/
|
||||
@Internal
|
||||
CellType getCellTypeEnum();
|
||||
|
||||
/**
|
||||
* Only valid for formula cells
|
||||
*
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||
* on the cached value of the formula
|
||||
*/
|
||||
int getCachedFormulaResultType();
|
||||
|
||||
/**
|
||||
* Only valid for formula cells
|
||||
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||
* on the cached value of the formula
|
||||
* @deprecated POI 3.15 beta 3
|
||||
*/
|
||||
CellType getCachedFormulaResultType();
|
||||
@Internal
|
||||
CellType getCachedFormulaResultTypeEnum();
|
||||
|
||||
/**
|
||||
* Set a numeric value for the cell
|
||||
@ -248,7 +275,7 @@ public interface Cell {
|
||||
* Return a formula for the cell, for example, <code>SUM(C4:E4)</code>
|
||||
*
|
||||
* @return a formula for the cell
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not {@link CellType#FORMULA}
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not {@link CellType#FORMULA}
|
||||
*/
|
||||
String getCellFormula();
|
||||
|
||||
@ -259,7 +286,7 @@ public interface Cell {
|
||||
* For formulas or error cells we return the precalculated value;
|
||||
* </p>
|
||||
* @return the value of the cell as a number
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING}
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING}
|
||||
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
|
||||
* @see DataFormatter for turning this number into a string similar to that which Excel would render this number as.
|
||||
*/
|
||||
@ -271,7 +298,7 @@ public interface Cell {
|
||||
* For strings we throw an exception. For blank cells we return a null.
|
||||
* </p>
|
||||
* @return the value of the cell as a date
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING}
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING}
|
||||
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
|
||||
* @see DataFormatter for formatting this date into a string similar to how excel does.
|
||||
*/
|
||||
@ -323,7 +350,7 @@ public interface Cell {
|
||||
* For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
|
||||
* </p>
|
||||
* @return the value of the cell as a boolean
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()}
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()}
|
||||
* is not {@link CellType#BOOLEAN}, {@link CellType#BLANK} or {@link CellType#FORMULA}
|
||||
*/
|
||||
boolean getBooleanCellValue();
|
||||
@ -336,7 +363,7 @@ public interface Cell {
|
||||
* </p>
|
||||
*
|
||||
* @return the value of the cell as an error code
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't {@link CellType#ERROR}
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType#ERROR}
|
||||
* @see FormulaError for error codes
|
||||
*/
|
||||
byte getErrorCellValue();
|
||||
|
@ -879,7 +879,7 @@ public class DataFormatter implements Observer {
|
||||
return "";
|
||||
}
|
||||
|
||||
CellType cellType = cell.getCellType();
|
||||
CellType cellType = cell.getCellTypeEnum();
|
||||
if (cellType == CellType.FORMULA) {
|
||||
if (evaluator == null) {
|
||||
return cell.getCellFormula();
|
||||
|
@ -81,7 +81,7 @@ public class SheetUtil {
|
||||
|
||||
public void evaluateAll() {}
|
||||
public CellType evaluateFormulaCell(Cell cell) {
|
||||
return cell.getCachedFormulaResultType();
|
||||
return cell.getCachedFormulaResultTypeEnum();
|
||||
}
|
||||
};
|
||||
|
||||
@ -120,11 +120,11 @@ public class SheetUtil {
|
||||
}
|
||||
|
||||
CellStyle style = cell.getCellStyle();
|
||||
CellType cellType = cell.getCellType();
|
||||
CellType cellType = cell.getCellTypeEnum();
|
||||
|
||||
// for formula cells we compute the cell width for the cached formula result
|
||||
if (cellType == CellType.FORMULA)
|
||||
cellType = cell.getCachedFormulaResultType();
|
||||
cellType = cell.getCachedFormulaResultTypeEnum();
|
||||
|
||||
Font font = wb.getFontAt(style.getFontIndex());
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class CellWalk {
|
||||
}
|
||||
|
||||
private boolean isEmpty(Cell cell) {
|
||||
return (cell.getCellType() == CellType.BLANK);
|
||||
return (cell.getCellTypeEnum() == CellType.BLANK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,19 +162,19 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor
|
||||
Cell cell = ri.next();
|
||||
|
||||
// Is it a formula one?
|
||||
if(cell.getCellType() == CellType.FORMULA) {
|
||||
if(cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
if (formulasNotResults) {
|
||||
String contents = cell.getCellFormula();
|
||||
checkMaxTextSize(text, contents);
|
||||
text.append(contents);
|
||||
} else {
|
||||
if (cell.getCachedFormulaResultType() == CellType.STRING) {
|
||||
if (cell.getCachedFormulaResultTypeEnum() == CellType.STRING) {
|
||||
handleStringCell(text, cell);
|
||||
} else {
|
||||
handleNonStringCell(text, cell, formatter);
|
||||
}
|
||||
}
|
||||
} else if(cell.getCellType() == CellType.STRING) {
|
||||
} else if(cell.getCellTypeEnum() == CellType.STRING) {
|
||||
handleStringCell(text, cell);
|
||||
} else {
|
||||
handleNonStringCell(text, cell, formatter);
|
||||
@ -236,9 +236,9 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor
|
||||
}
|
||||
|
||||
private void handleNonStringCell(StringBuffer text, Cell cell, DataFormatter formatter) {
|
||||
CellType type = cell.getCellType();
|
||||
CellType type = cell.getCellTypeEnum();
|
||||
if (type == CellType.FORMULA) {
|
||||
type = cell.getCachedFormulaResultType();
|
||||
type = cell.getCachedFormulaResultTypeEnum();
|
||||
}
|
||||
|
||||
if (type == CellType.NUMERIC) {
|
||||
|
@ -278,13 +278,13 @@ public class XSSFExportToXml implements Comparator<String>{
|
||||
private void mapCellOnNode(XSSFCell cell, Node node, STXmlDataType.Enum outputDataType) {
|
||||
|
||||
String value ="";
|
||||
switch (cell.getCellType()) {
|
||||
switch (cell.getCellTypeEnum()) {
|
||||
|
||||
case STRING: value = cell.getStringCellValue(); break;
|
||||
case BOOLEAN: value += cell.getBooleanCellValue(); break;
|
||||
case ERROR: value = cell.getErrorCellString(); break;
|
||||
case FORMULA:
|
||||
if (cell.getCachedFormulaResultType() == CellType.STRING) {
|
||||
if (cell.getCachedFormulaResultTypeEnum() == CellType.STRING) {
|
||||
value = cell.getStringCellValue();
|
||||
} else {
|
||||
if (DateUtil.isCellDateFormatted(cell)) {
|
||||
|
@ -38,6 +38,7 @@ import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.util.CellAddress;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.CellReference;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.LocaleUtil;
|
||||
import org.apache.poi.util.NotImplemented;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
@ -150,7 +151,20 @@ public class SXSSFCell implements Cell {
|
||||
* @return the cell type
|
||||
*/
|
||||
@Override
|
||||
public CellType getCellType()
|
||||
public int getCellType()
|
||||
{
|
||||
return getCellTypeEnum().getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cell type.
|
||||
*
|
||||
* @return the cell type
|
||||
* @deprecated POI 3.15 beta 3
|
||||
*/
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCellTypeEnum()
|
||||
{
|
||||
return _value.getType();
|
||||
}
|
||||
@ -162,7 +176,21 @@ public class SXSSFCell implements Cell {
|
||||
* on the cached value of the formula
|
||||
*/
|
||||
@Override
|
||||
public CellType getCachedFormulaResultType()
|
||||
public int getCachedFormulaResultType()
|
||||
{
|
||||
return getCachedFormulaResultTypeEnum().getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Only valid for formula cells
|
||||
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||
* on the cached value of the formula
|
||||
* @deprecated POI 3.15 beta 3.
|
||||
*/
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCachedFormulaResultTypeEnum()
|
||||
{
|
||||
if (_value.getType() != CellType.FORMULA) {
|
||||
throw new IllegalStateException("Only formula cells have cached results");
|
||||
@ -330,7 +358,7 @@ public class SXSSFCell implements Cell {
|
||||
* Return a formula for the cell, for example, <code>SUM(C4:E4)</code>
|
||||
*
|
||||
* @return a formula for the cell
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not CellType.FORMULA
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not CellType.FORMULA
|
||||
*/
|
||||
@Override
|
||||
public String getCellFormula()
|
||||
@ -347,14 +375,14 @@ public class SXSSFCell implements Cell {
|
||||
* For formulas or error cells we return the precalculated value;
|
||||
* </p>
|
||||
* @return the value of the cell as a number
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is CellType.STRING
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is CellType.STRING
|
||||
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
|
||||
* @see org.apache.poi.ss.usermodel.DataFormatter for turning this number into a string similar to that which Excel would render this number as.
|
||||
*/
|
||||
@Override
|
||||
public double getNumericCellValue()
|
||||
{
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
switch(cellType)
|
||||
{
|
||||
case BLANK:
|
||||
@ -379,14 +407,14 @@ public class SXSSFCell implements Cell {
|
||||
* For strings we throw an exception. For blank cells we return a null.
|
||||
* </p>
|
||||
* @return the value of the cell as a date
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is CellType.STRING
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is CellType.STRING
|
||||
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
|
||||
* @see org.apache.poi.ss.usermodel.DataFormatter for formatting this date into a string similar to how excel does.
|
||||
*/
|
||||
@Override
|
||||
public Date getDateCellValue()
|
||||
{
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
if (cellType == CellType.BLANK)
|
||||
{
|
||||
return null;
|
||||
@ -408,8 +436,8 @@ public class SXSSFCell implements Cell {
|
||||
@Override
|
||||
public RichTextString getRichStringCellValue()
|
||||
{
|
||||
CellType cellType = getCellType();
|
||||
if(getCellType() != CellType.STRING)
|
||||
CellType cellType = getCellTypeEnum();
|
||||
if(getCellTypeEnum() != CellType.STRING)
|
||||
throw typeMismatch(CellType.STRING, cellType, false);
|
||||
|
||||
StringValue sval = (StringValue)_value;
|
||||
@ -433,7 +461,7 @@ public class SXSSFCell implements Cell {
|
||||
@Override
|
||||
public String getStringCellValue()
|
||||
{
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
switch(cellType)
|
||||
{
|
||||
case BLANK:
|
||||
@ -499,13 +527,13 @@ public class SXSSFCell implements Cell {
|
||||
* For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
|
||||
* </p>
|
||||
* @return the value of the cell as a boolean
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()}
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()}
|
||||
* is not CellType.BOOLEAN, CellType.BLANK or CellType.FORMULA
|
||||
*/
|
||||
@Override
|
||||
public boolean getBooleanCellValue()
|
||||
{
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
switch(cellType)
|
||||
{
|
||||
case BLANK:
|
||||
@ -534,13 +562,13 @@ public class SXSSFCell implements Cell {
|
||||
* </p>
|
||||
*
|
||||
* @return the value of the cell as an error code
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't CellType.ERROR
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't CellType.ERROR
|
||||
* @see org.apache.poi.ss.usermodel.FormulaError for error codes
|
||||
*/
|
||||
@Override
|
||||
public byte getErrorCellValue()
|
||||
{
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
switch(cellType)
|
||||
{
|
||||
case BLANK:
|
||||
@ -714,7 +742,7 @@ public class SXSSFCell implements Cell {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
switch (getCellType()) {
|
||||
switch (getCellTypeEnum()) {
|
||||
case BLANK:
|
||||
return "";
|
||||
case BOOLEAN:
|
||||
@ -733,7 +761,7 @@ public class SXSSFCell implements Cell {
|
||||
case STRING:
|
||||
return getRichStringCellValue().toString();
|
||||
default:
|
||||
return "Unknown Cell Type: " + getCellType();
|
||||
return "Unknown Cell Type: " + getCellTypeEnum();
|
||||
}
|
||||
}
|
||||
|
||||
@ -959,10 +987,10 @@ public class SXSSFCell implements Cell {
|
||||
}
|
||||
|
||||
private boolean convertCellValueToBoolean() {
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
|
||||
if (cellType == CellType.FORMULA) {
|
||||
cellType = getCachedFormulaResultType();
|
||||
cellType = getCachedFormulaResultTypeEnum();
|
||||
}
|
||||
|
||||
switch (cellType) {
|
||||
@ -982,7 +1010,7 @@ public class SXSSFCell implements Cell {
|
||||
|
||||
}
|
||||
private String convertCellValueToString() {
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
return convertCellValueToString(cellType);
|
||||
}
|
||||
private String convertCellValueToString(CellType cellType) {
|
||||
|
@ -20,6 +20,7 @@ package org.apache.poi.xssf.streaming;
|
||||
import org.apache.poi.ss.formula.EvaluationCell;
|
||||
import org.apache.poi.ss.formula.EvaluationSheet;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.util.Internal;
|
||||
|
||||
/**
|
||||
* SXSSF wrapper for a cell under evaluation
|
||||
@ -51,10 +52,22 @@ final class SXSSFEvaluationCell implements EvaluationCell {
|
||||
public boolean getBooleanCellValue() {
|
||||
return _cell.getBooleanCellValue();
|
||||
}
|
||||
/**
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return cell type
|
||||
*/
|
||||
@Override
|
||||
public CellType getCellType() {
|
||||
public int getCellType() {
|
||||
return _cell.getCellType();
|
||||
}
|
||||
/** @deprecated POI 3.15 beta 3 */
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCellTypeEnum() {
|
||||
return _cell.getCellTypeEnum();
|
||||
}
|
||||
@Override
|
||||
public int getColumnIndex() {
|
||||
return _cell.getColumnIndex();
|
||||
@ -78,9 +91,21 @@ final class SXSSFEvaluationCell implements EvaluationCell {
|
||||
@Override
|
||||
public String getStringCellValue() {
|
||||
return _cell.getRichStringCellValue().getString();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return cell type of cached formula result
|
||||
*/
|
||||
@Override
|
||||
public CellType getCachedFormulaResultType() {
|
||||
return _cell.getCachedFormulaResultType();
|
||||
public int getCachedFormulaResultType() {
|
||||
return _cell.getCachedFormulaResultType();
|
||||
}
|
||||
/** @deprecated POI 3.15 beta 3 */
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCachedFormulaResultTypeEnum() {
|
||||
return _cell.getCachedFormulaResultTypeEnum();
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public final class SXSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator {
|
||||
// Evaluate what we have
|
||||
for (Row r : sheet) {
|
||||
for (Cell c : r) {
|
||||
if (c.getCellType() == CellType.FORMULA) {
|
||||
if (c.getCellTypeEnum() == CellType.FORMULA) {
|
||||
eval.evaluateFormulaCell(c);
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ public class SXSSFRow implements Row, Comparable<SXSSFRow>
|
||||
case RETURN_NULL_AND_BLANK:
|
||||
return cell;
|
||||
case RETURN_BLANK_AS_NULL:
|
||||
boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK);
|
||||
boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK);
|
||||
return (isBlank) ? null : cell;
|
||||
case CREATE_NULL_AS_BLANK:
|
||||
return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;
|
||||
|
@ -202,7 +202,7 @@ public class SheetDataWriter {
|
||||
// APIs
|
||||
_out.write(" s=\"" + (cellStyle.getIndex() & 0xffff) + "\"");
|
||||
}
|
||||
CellType cellType = cell.getCellType();
|
||||
CellType cellType = cell.getCellTypeEnum();
|
||||
switch (cellType) {
|
||||
case BLANK: {
|
||||
_out.write(">");
|
||||
@ -213,7 +213,7 @@ public class SheetDataWriter {
|
||||
_out.write("<f>");
|
||||
outputQuotedString(cell.getCellFormula());
|
||||
_out.write("</f>");
|
||||
switch (cell.getCachedFormulaResultType()) {
|
||||
switch (cell.getCachedFormulaResultTypeEnum()) {
|
||||
case NUMERIC:
|
||||
double nval = cell.getNumericCellValue();
|
||||
if (!Double.isNaN(nval)) {
|
||||
|
@ -75,7 +75,7 @@ public abstract class BaseXSSFFormulaEvaluator implements FormulaEvaluator, Work
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (cell.getCellType()) {
|
||||
switch (cell.getCellTypeEnum()) {
|
||||
case BOOLEAN:
|
||||
return CellValue.valueOf(cell.getBooleanCellValue());
|
||||
case ERROR:
|
||||
@ -89,7 +89,7 @@ public abstract class BaseXSSFFormulaEvaluator implements FormulaEvaluator, Work
|
||||
case BLANK:
|
||||
return null;
|
||||
default:
|
||||
throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
|
||||
throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ public abstract class BaseXSSFFormulaEvaluator implements FormulaEvaluator, Work
|
||||
* @return The type of the formula result (the cell's type remains as CellType.FORMULA however)
|
||||
*/
|
||||
public CellType evaluateFormulaCell(Cell cell) {
|
||||
if (cell == null || cell.getCellType() != CellType.FORMULA) {
|
||||
if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
|
||||
return CellType._UNINITIALIZED;
|
||||
}
|
||||
CellValue cv = evaluateFormulaCellValue(cell);
|
||||
@ -131,7 +131,7 @@ public abstract class BaseXSSFFormulaEvaluator implements FormulaEvaluator, Work
|
||||
*/
|
||||
protected void doEvaluateInCell(Cell cell) {
|
||||
if (cell == null) return;
|
||||
if (cell.getCellType() == CellType.FORMULA) {
|
||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
CellValue cv = evaluateFormulaCellValue(cell);
|
||||
setCellType(cell, cv); // cell will no longer be a formula cell
|
||||
setCellValue(cell, cv);
|
||||
|
@ -138,11 +138,11 @@ public final class XSSFCell implements Cell {
|
||||
// Copy cell value (cell type is updated implicitly)
|
||||
if (policy.isCopyCellValue()) {
|
||||
if (srcCell != null) {
|
||||
CellType copyCellType = srcCell.getCellType();
|
||||
CellType copyCellType = srcCell.getCellTypeEnum();
|
||||
if (copyCellType == CellType.FORMULA && !policy.isCopyCellFormula()) {
|
||||
// Copy formula result as value
|
||||
// FIXME: Cached value may be stale
|
||||
copyCellType = srcCell.getCachedFormulaResultType();
|
||||
copyCellType = srcCell.getCachedFormulaResultTypeEnum();
|
||||
}
|
||||
switch (copyCellType) {
|
||||
case NUMERIC:
|
||||
@ -171,7 +171,7 @@ public final class XSSFCell implements Cell {
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid cell type " + srcCell.getCellType());
|
||||
throw new IllegalArgumentException("Invalid cell type " + srcCell.getCellTypeEnum());
|
||||
}
|
||||
} else { //srcCell is null
|
||||
setBlank();
|
||||
@ -249,12 +249,12 @@ public final class XSSFCell implements Cell {
|
||||
* For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
|
||||
* </p>
|
||||
* @return the value of the cell as a boolean
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()}
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()}
|
||||
* is not {@link CellType#BOOLEAN}, {@link CellType#BLANK} or {@link CellType#FORMULA}
|
||||
*/
|
||||
@Override
|
||||
public boolean getBooleanCellValue() {
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
switch(cellType) {
|
||||
case BLANK:
|
||||
return false;
|
||||
@ -288,13 +288,13 @@ public final class XSSFCell implements Cell {
|
||||
* For formulas or error cells we return the precalculated value;
|
||||
* </p>
|
||||
* @return the value of the cell as a number
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING}
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING}
|
||||
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
|
||||
* @see DataFormatter for turning this number into a string similar to that which Excel would render this number as.
|
||||
*/
|
||||
@Override
|
||||
public double getNumericCellValue() {
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
switch(cellType) {
|
||||
case BLANK:
|
||||
return 0.0;
|
||||
@ -366,7 +366,7 @@ public final class XSSFCell implements Cell {
|
||||
*/
|
||||
@Override
|
||||
public XSSFRichTextString getRichStringCellValue() {
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
XSSFRichTextString rt;
|
||||
switch (cellType) {
|
||||
case BLANK:
|
||||
@ -445,7 +445,7 @@ public final class XSSFCell implements Cell {
|
||||
throw new IllegalArgumentException("The maximum length of cell contents (text) is 32,767 characters");
|
||||
}
|
||||
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
switch (cellType){
|
||||
case FORMULA:
|
||||
_cell.setV(str.getString());
|
||||
@ -470,7 +470,7 @@ public final class XSSFCell implements Cell {
|
||||
* Return a formula for the cell, for example, <code>SUM(C4:E4)</code>
|
||||
*
|
||||
* @return a formula for the cell
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not {@link CellType#FORMULA}
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not {@link CellType#FORMULA}
|
||||
*/
|
||||
@Override
|
||||
public String getCellFormula() {
|
||||
@ -483,10 +483,10 @@ public final class XSSFCell implements Cell {
|
||||
*
|
||||
* @param fpb evaluation workbook for reuse, if available, or null to create a new one as needed
|
||||
* @return a formula for the cell
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not {@link CellType#FORMULA}
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not {@link CellType#FORMULA}
|
||||
*/
|
||||
protected String getCellFormula(XSSFEvaluationWorkbook fpb) {
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
if(cellType != CellType.FORMULA) throw typeMismatch(CellType.FORMULA, cellType, false);
|
||||
|
||||
CTCellFormula f = _cell.getF();
|
||||
@ -660,14 +660,29 @@ public final class XSSFCell implements Cell {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cell type.
|
||||
*
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return the cell type
|
||||
*/
|
||||
@Override
|
||||
public int getCellType() {
|
||||
return getCellTypeEnum().getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cell type.
|
||||
*
|
||||
* @return the cell type
|
||||
* @deprecated POI 3.15 beta 3
|
||||
*/
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCellType() {
|
||||
public CellType getCellTypeEnum() {
|
||||
if (isFormulaCell()) return CellType.FORMULA;
|
||||
|
||||
return getBaseCellType(true);
|
||||
@ -675,12 +690,29 @@ public final class XSSFCell implements Cell {
|
||||
|
||||
/**
|
||||
* Only valid for formula cells
|
||||
*
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||
* on the cached value of the formula
|
||||
*/
|
||||
@Override
|
||||
public CellType getCachedFormulaResultType() {
|
||||
public int getCachedFormulaResultType() {
|
||||
return getCachedFormulaResultTypeEnum().getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Only valid for formula cells
|
||||
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||
* on the cached value of the formula
|
||||
* @deprecated POI 3.15 beta 3
|
||||
*/
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCachedFormulaResultTypeEnum() {
|
||||
if (! isFormulaCell()) {
|
||||
throw new IllegalStateException("Only formula cells have cached results");
|
||||
}
|
||||
@ -722,13 +754,13 @@ public final class XSSFCell implements Cell {
|
||||
* For strings we throw an exception. For blank cells we return a null.
|
||||
* </p>
|
||||
* @return the value of the cell as a date
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING}
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING}
|
||||
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
|
||||
* @see DataFormatter for formatting this date into a string similar to how excel does.
|
||||
*/
|
||||
@Override
|
||||
public Date getDateCellValue() {
|
||||
if (getCellType() == CellType.BLANK) {
|
||||
if (getCellTypeEnum() == CellType.BLANK) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -787,7 +819,7 @@ public final class XSSFCell implements Cell {
|
||||
* Returns the error message, such as #VALUE!
|
||||
*
|
||||
* @return the error message such as #VALUE!
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't {@link CellType#ERROR}
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType#ERROR}
|
||||
* @see FormulaError
|
||||
*/
|
||||
public String getErrorCellString() {
|
||||
@ -804,7 +836,7 @@ public final class XSSFCell implements Cell {
|
||||
* </p>
|
||||
*
|
||||
* @return the value of the cell as an error code
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't {@link CellType #ERROR}
|
||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType #ERROR}
|
||||
* @see FormulaError
|
||||
*/
|
||||
@Override
|
||||
@ -899,7 +931,7 @@ public final class XSSFCell implements Cell {
|
||||
*/
|
||||
@Override
|
||||
public void setCellType(CellType cellType) {
|
||||
CellType prevType = getCellType();
|
||||
CellType prevType = getCellTypeEnum();
|
||||
|
||||
if(isPartOfArrayFormulaGroup()){
|
||||
notifyArrayFormulaChanging();
|
||||
@ -962,7 +994,7 @@ public final class XSSFCell implements Cell {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
switch (getCellType()) {
|
||||
switch (getCellTypeEnum()) {
|
||||
case NUMERIC:
|
||||
if (DateUtil.isCellDateFormatted(this)) {
|
||||
DateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", LocaleUtil.getUserLocale());
|
||||
@ -981,7 +1013,7 @@ public final class XSSFCell implements Cell {
|
||||
case ERROR:
|
||||
return ErrorEval.getText(getErrorCellValue());
|
||||
default:
|
||||
return "Unknown Cell Type: " + getCellType();
|
||||
return "Unknown Cell Type: " + getCellTypeEnum();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1133,7 +1165,7 @@ public final class XSSFCell implements Cell {
|
||||
* TODO - perhaps a method like setCellTypeAndValue(int, Object) should be introduced to avoid this
|
||||
*/
|
||||
private boolean convertCellValueToBoolean() {
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
|
||||
if (cellType == CellType.FORMULA) {
|
||||
cellType = getBaseCellType(false);
|
||||
@ -1161,7 +1193,7 @@ public final class XSSFCell implements Cell {
|
||||
}
|
||||
|
||||
private String convertCellValueToString() {
|
||||
CellType cellType = getCellType();
|
||||
CellType cellType = getCellTypeEnum();
|
||||
|
||||
switch (cellType) {
|
||||
case BLANK:
|
||||
|
@ -20,6 +20,7 @@ package org.apache.poi.xssf.usermodel;
|
||||
import org.apache.poi.ss.formula.EvaluationCell;
|
||||
import org.apache.poi.ss.formula.EvaluationSheet;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.util.Internal;
|
||||
|
||||
/**
|
||||
* XSSF wrapper for a cell under evaluation
|
||||
@ -52,10 +53,22 @@ final class XSSFEvaluationCell implements EvaluationCell {
|
||||
public boolean getBooleanCellValue() {
|
||||
return _cell.getBooleanCellValue();
|
||||
}
|
||||
/**
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return cell type
|
||||
*/
|
||||
@Override
|
||||
public CellType getCellType() {
|
||||
public int getCellType() {
|
||||
return _cell.getCellType();
|
||||
}
|
||||
/** @deprecated POI 3.15 beta 3 */
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCellTypeEnum() {
|
||||
return _cell.getCellTypeEnum();
|
||||
}
|
||||
@Override
|
||||
public int getColumnIndex() {
|
||||
return _cell.getColumnIndex();
|
||||
@ -79,9 +92,21 @@ final class XSSFEvaluationCell implements EvaluationCell {
|
||||
@Override
|
||||
public String getStringCellValue() {
|
||||
return _cell.getRichStringCellValue().getString();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Will return {@link CellType} in a future version of POI.
|
||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
||||
*
|
||||
* @return cell type of cached formula result
|
||||
*/
|
||||
@Override
|
||||
public CellType getCachedFormulaResultType() {
|
||||
return _cell.getCachedFormulaResultType();
|
||||
public int getCachedFormulaResultType() {
|
||||
return _cell.getCachedFormulaResultType();
|
||||
}
|
||||
/** @deprecated POI 3.15 beta 3 */
|
||||
@Internal
|
||||
@Override
|
||||
public CellType getCachedFormulaResultTypeEnum() {
|
||||
return _cell.getCachedFormulaResultTypeEnum();
|
||||
}
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
|
||||
case RETURN_NULL_AND_BLANK:
|
||||
return cell;
|
||||
case RETURN_BLANK_AS_NULL:
|
||||
boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK);
|
||||
boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK);
|
||||
return (isBlank) ? null : cell;
|
||||
case CREATE_NULL_AS_BLANK:
|
||||
return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;
|
||||
@ -496,7 +496,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
|
||||
if(xcell.isPartOfArrayFormulaGroup()) {
|
||||
xcell.notifyArrayFormulaChanging();
|
||||
}
|
||||
if(cell.getCellType() == CellType.FORMULA) {
|
||||
if(cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
_sheet.getWorkbook().onDeleteFormula(xcell);
|
||||
}
|
||||
// Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory
|
||||
@ -636,7 +636,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
|
||||
else {
|
||||
for (final Cell c : srcRow){
|
||||
final XSSFCell srcCell = (XSSFCell)c;
|
||||
final XSSFCell destCell = createCell(srcCell.getColumnIndex(), srcCell.getCellType());
|
||||
final XSSFCell destCell = createCell(srcCell.getColumnIndex(), srcCell.getCellTypeEnum());
|
||||
destCell.copyCellFrom(srcCell, policy);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public final class XSSFFormulaUtils {
|
||||
for (Sheet sh : _wb) {
|
||||
for (Row row : sh) {
|
||||
for (Cell cell : row) {
|
||||
if (cell.getCellType() == CellType.FORMULA) {
|
||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
updateFormula((XSSFCell) cell, oldName, newName);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public final class TestCalculationChain extends TestCase {
|
||||
XSSFSheet sheet = wb.getSheet("Test");
|
||||
XSSFCell cell = sheet.getRow(0).getCell(4);
|
||||
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
cell.setCellFormula(null);
|
||||
|
||||
//the count of items is less by one
|
||||
@ -53,9 +53,9 @@ public final class TestCalculationChain extends TestCase {
|
||||
assertEquals(10, c.getI());
|
||||
assertEquals("C1", c.getR());
|
||||
|
||||
assertEquals(CellType.STRING, cell.getCellType());
|
||||
assertEquals(CellType.STRING, cell.getCellTypeEnum());
|
||||
cell.setCellValue("ABC");
|
||||
assertEquals(CellType.STRING, cell.getCellType());
|
||||
assertEquals(CellType.STRING, cell.getCellTypeEnum());
|
||||
}
|
||||
|
||||
|
||||
|
@ -190,7 +190,7 @@ public final class TestFormulaEvaluatorOnXSSF {
|
||||
for (short colnum=SS.COLUMN_INDEX_FIRST_TEST_VALUE; colnum < endcolnum; colnum++) {
|
||||
Cell c = formulasRow.getCell(colnum);
|
||||
assumeNotNull(c);
|
||||
assumeTrue(c.getCellType() == CellType.FORMULA);
|
||||
assumeTrue(c.getCellTypeEnum() == CellType.FORMULA);
|
||||
ignoredFormulaTestCase(c.getCellFormula());
|
||||
|
||||
CellValue actValue = evaluator.evaluate(c);
|
||||
@ -202,7 +202,7 @@ public final class TestFormulaEvaluatorOnXSSF {
|
||||
assertNotNull(msg + " - Bad setup data expected value is null", expValue);
|
||||
assertNotNull(msg + " - actual value was null", actValue);
|
||||
|
||||
final CellType expectedCellType = expValue.getCellType();
|
||||
final CellType expectedCellType = expValue.getCellTypeEnum();
|
||||
switch (expectedCellType) {
|
||||
case BLANK:
|
||||
assertEquals(msg, CellType.BLANK, actValue.getCellType());
|
||||
@ -264,10 +264,10 @@ public final class TestFormulaEvaluatorOnXSSF {
|
||||
logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name");
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.BLANK) {
|
||||
if(cell.getCellTypeEnum() == CellType.BLANK) {
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.STRING) {
|
||||
if(cell.getCellTypeEnum() == CellType.STRING) {
|
||||
return cell.getRichStringCellValue().getString();
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF {
|
||||
|
||||
Cell c = r.getCell(SS.COLUMN_INDEX_ACTUAL_VALUE);
|
||||
assumeNotNull(c);
|
||||
assumeTrue(c.getCellType() == CellType.FORMULA);
|
||||
assumeTrue(c.getCellTypeEnum() == CellType.FORMULA);
|
||||
|
||||
CellValue actValue = evaluator.evaluate(c);
|
||||
|
||||
@ -185,7 +185,7 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF {
|
||||
|
||||
assertNotNull(msg + " - actual value was null", actValue);
|
||||
|
||||
final CellType expectedCellType = expValue.getCellType();
|
||||
final CellType expectedCellType = expValue.getCellTypeEnum();
|
||||
switch (expectedCellType) {
|
||||
case BLANK:
|
||||
assertEquals(msg, CellType.BLANK, actValue.getCellType());
|
||||
@ -231,15 +231,15 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF {
|
||||
logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name");
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.BLANK) {
|
||||
if(cell.getCellTypeEnum() == CellType.BLANK) {
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.STRING) {
|
||||
if(cell.getCellTypeEnum() == CellType.STRING) {
|
||||
return cell.getRichStringCellValue().getString();
|
||||
}
|
||||
|
||||
fail("Bad cell type for 'function name' column: ("
|
||||
+ cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
|
||||
+ cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")");
|
||||
return "";
|
||||
}
|
||||
/**
|
||||
@ -255,15 +255,15 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF {
|
||||
logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_TEST_NAME + ", can't figure out test name");
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.BLANK) {
|
||||
if(cell.getCellTypeEnum() == CellType.BLANK) {
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.STRING) {
|
||||
if(cell.getCellTypeEnum() == CellType.STRING) {
|
||||
return cell.getRichStringCellValue().getString();
|
||||
}
|
||||
|
||||
fail("Bad cell type for 'test name' column: ("
|
||||
+ cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
|
||||
+ cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")");
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
Sheet s = wb.getSheetAt(i);
|
||||
for(Row r : s) {
|
||||
for(Cell c : r) {
|
||||
if(c.getCellType() == CellType.FORMULA) {
|
||||
if(c.getCellTypeEnum() == CellType.FORMULA) {
|
||||
CellValue cv = eval.evaluate(c);
|
||||
|
||||
if(cv.getCellType() == CellType.NUMERIC) {
|
||||
@ -424,7 +424,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
cell = sheet.getRow(0).getCell(0);
|
||||
assertEquals("#REF!*#REF!", cell.getCellFormula());
|
||||
assertEquals(CellType.ERROR, evaluator.evaluateInCell(cell).getCellType());
|
||||
assertEquals(CellType.ERROR, evaluator.evaluateInCell(cell).getCellTypeEnum());
|
||||
assertEquals("#REF!", FormulaError.forInt(cell.getErrorCellValue()).getString());
|
||||
|
||||
Name nm1 = wb.getName("sale_1");
|
||||
@ -436,7 +436,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
cell = sheet.getRow(1).getCell(0);
|
||||
assertEquals("sale_1*sale_2", cell.getCellFormula());
|
||||
assertEquals(CellType.ERROR, evaluator.evaluateInCell(cell).getCellType());
|
||||
assertEquals(CellType.ERROR, evaluator.evaluateInCell(cell).getCellTypeEnum());
|
||||
assertEquals("#REF!", FormulaError.forInt(cell.getErrorCellValue()).getString());
|
||||
|
||||
wb.close();
|
||||
@ -642,7 +642,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
Sheet sheet = wb.getSheetAt(0);
|
||||
for(Row row : sheet){
|
||||
for(Cell cell : row){
|
||||
if(cell.getCellType() == CellType.FORMULA){
|
||||
if(cell.getCellTypeEnum() == CellType.FORMULA){
|
||||
formulaEvaluator.evaluateInCell(cell); // caused NPE on some cells
|
||||
}
|
||||
}
|
||||
@ -1696,7 +1696,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// Get wrong cell by row 8 & column 7
|
||||
Cell cell = sheet.getRow(8).getCell(7);
|
||||
assertEquals(CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
|
||||
// Check the value - will be zero as it is <c><v/></c>
|
||||
assertEquals(0.0, cell.getNumericCellValue(), 0.001);
|
||||
@ -2182,7 +2182,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
Sheet sheet = wb.getSheet("Sheet1");
|
||||
Cell cell = sheet.getRow(5).getCell(4);
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("E4+E5", cell.getCellFormula());
|
||||
|
||||
CellValue value = evaluator.evaluate(cell);
|
||||
@ -2541,7 +2541,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
if(cell == null){
|
||||
cell = row.createCell(cellnum);
|
||||
} else {
|
||||
if(cell.getCellType() == CellType.FORMULA) {
|
||||
if(cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
cell.setCellFormula(null);
|
||||
cell.getCellStyle().setDataFormat((short) 0);
|
||||
}
|
||||
@ -2607,13 +2607,13 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
}
|
||||
|
||||
private void assertFormula(Workbook wb, Cell intF, String expectedFormula, String expectedResultOrNull) {
|
||||
assertEquals(CellType.FORMULA, intF.getCellType());
|
||||
assertEquals(CellType.FORMULA, intF.getCellTypeEnum());
|
||||
if (null == expectedResultOrNull) {
|
||||
assertEquals(CellType.ERROR, intF.getCachedFormulaResultType());
|
||||
assertEquals(CellType.ERROR, intF.getCachedFormulaResultTypeEnum());
|
||||
expectedResultOrNull = "#VALUE!";
|
||||
}
|
||||
else {
|
||||
assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultType());
|
||||
assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultTypeEnum());
|
||||
}
|
||||
|
||||
assertEquals(expectedFormula, intF.getCellFormula());
|
||||
@ -2654,7 +2654,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
Sheet sheet = wb.getSheet("Sheet1");
|
||||
for(Row aRow : sheet) {
|
||||
Cell cell = aRow.getCell(1);
|
||||
if(cell.getCellType() == CellType.FORMULA) {
|
||||
if(cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
String formula = cell.getCellFormula();
|
||||
//System.out.println("formula: " + formula);
|
||||
assertNotNull(formula);
|
||||
@ -2958,14 +2958,14 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
row = worksheet.getRow(2);
|
||||
cell = row.getCell(1);
|
||||
|
||||
assertEquals(CellType.BLANK, cell.getCellType());
|
||||
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
|
||||
assertEquals(CellType._UNINITIALIZED, evaluator.evaluateFormulaCell(cell));
|
||||
|
||||
// A3
|
||||
row = worksheet.getRow(2);
|
||||
cell = row.getCell(0);
|
||||
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("IF(ISBLANK(B3),\"\",B3)", cell.getCellFormula());
|
||||
assertEquals(CellType.STRING, evaluator.evaluateFormulaCell(cell));
|
||||
CellValue value = evaluator.evaluate(cell);
|
||||
@ -2975,7 +2975,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
row = worksheet.getRow(4);
|
||||
cell = row.getCell(0);
|
||||
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("COUNTBLANK(A1:A4)", cell.getCellFormula());
|
||||
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(cell));
|
||||
value = evaluator.evaluate(cell);
|
||||
|
@ -134,13 +134,13 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||
assertNull(str.getString());
|
||||
cell_0.setCellValue(str);
|
||||
assertEquals(0, sst.getCount());
|
||||
assertEquals(CellType.BLANK, cell_0.getCellType());
|
||||
assertEquals(CellType.BLANK, cell_0.getCellTypeEnum());
|
||||
|
||||
//case 2. cell.setCellValue((String)null);
|
||||
Cell cell_1 = row.createCell(1);
|
||||
cell_1.setCellValue((String)null);
|
||||
assertEquals(0, sst.getCount());
|
||||
assertEquals(CellType.BLANK, cell_1.getCellType());
|
||||
assertEquals(CellType.BLANK, cell_1.getCellTypeEnum());
|
||||
wb.close();
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||
CTCell ctCell = cell.getCTCell(); //low-level bean holding cell's xml
|
||||
|
||||
cell.setCellFormula("A2");
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("A2", cell.getCellFormula());
|
||||
//the value is not set and cell's type='N' which means blank
|
||||
assertEquals(STCellType.N, ctCell.getT());
|
||||
@ -160,7 +160,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||
//set cached formula value
|
||||
cell.setCellValue("t='str'");
|
||||
//we are still of 'formula' type
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("A2", cell.getCellFormula());
|
||||
//cached formula value is set and cell's type='STR'
|
||||
assertEquals(STCellType.STR, ctCell.getT());
|
||||
@ -168,14 +168,14 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||
|
||||
//now remove the formula, the cached formula result remains
|
||||
cell.setCellFormula(null);
|
||||
assertEquals(CellType.STRING, cell.getCellType());
|
||||
assertEquals(CellType.STRING, cell.getCellTypeEnum());
|
||||
assertEquals(STCellType.STR, ctCell.getT());
|
||||
//the line below failed prior to fix of Bug #47889
|
||||
assertEquals("t='str'", cell.getStringCellValue());
|
||||
|
||||
//revert to a blank cell
|
||||
cell.setCellValue((String)null);
|
||||
assertEquals(CellType.BLANK, cell.getCellType());
|
||||
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
|
||||
assertEquals(STCellType.N, ctCell.getT());
|
||||
assertEquals("", cell.getStringCellValue());
|
||||
} finally {
|
||||
@ -195,7 +195,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||
|
||||
//try a string cell
|
||||
cell = sh.getRow(0).getCell(0);
|
||||
assertEquals(CellType.STRING, cell.getCellType());
|
||||
assertEquals(CellType.STRING, cell.getCellTypeEnum());
|
||||
assertEquals("a", cell.getStringCellValue());
|
||||
assertEquals("a", cell.toString());
|
||||
//Gnumeric produces spreadsheets without styles
|
||||
@ -204,7 +204,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||
|
||||
//try a numeric cell
|
||||
cell = sh.getRow(1).getCell(0);
|
||||
assertEquals(CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertEquals(1.0, cell.getNumericCellValue(), 0);
|
||||
assertEquals("1.0", cell.toString());
|
||||
//Gnumeric produces spreadsheets without styles
|
||||
@ -514,7 +514,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||
final CellCopyPolicy policy = new CellCopyPolicy();
|
||||
destCell.copyCellFrom(srcCell, policy);
|
||||
|
||||
assertEquals(CellType.FORMULA, destCell.getCellType());
|
||||
assertEquals(CellType.FORMULA, destCell.getCellTypeEnum());
|
||||
assertEquals("2+3", destCell.getCellFormula());
|
||||
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
|
||||
}
|
||||
@ -526,7 +526,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||
// Paste values only
|
||||
final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellFormula(false).build();
|
||||
destCell.copyCellFrom(srcCell, policy);
|
||||
assertEquals(CellType.NUMERIC, destCell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, destCell.getCellTypeEnum());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -553,8 +553,8 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
|
||||
|
||||
// Old cell value should not have been overwritten
|
||||
assertNotEquals(CellType.BLANK, destCell.getCellType());
|
||||
assertEquals(CellType.BOOLEAN, destCell.getCellType());
|
||||
assertNotEquals(CellType.BLANK, destCell.getCellTypeEnum());
|
||||
assertEquals(CellType.BOOLEAN, destCell.getCellTypeEnum());
|
||||
assertEquals(true, destCell.getBooleanCellValue());
|
||||
}
|
||||
|
||||
|
@ -576,9 +576,9 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
|
||||
|
||||
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
|
||||
|
||||
assertEquals(CellType.ERROR, getCell(sheet, 0,0).getCachedFormulaResultType());
|
||||
assertEquals(CellType.ERROR, getCell(sheet, 0,0).getCachedFormulaResultTypeEnum());
|
||||
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0,0).getErrorCellValue());
|
||||
assertEquals(CellType.ERROR, getCell(sheet, 0,1).getCachedFormulaResultType());
|
||||
assertEquals(CellType.ERROR, getCell(sheet, 0,1).getCachedFormulaResultTypeEnum());
|
||||
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0,1).getErrorCellValue());
|
||||
|
||||
wb.close();
|
||||
@ -597,11 +597,11 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
|
||||
|
||||
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
|
||||
|
||||
assertEquals(CellType.ERROR, getCell(sheet, 0, 0).getCachedFormulaResultType());
|
||||
assertEquals(CellType.ERROR, getCell(sheet, 0, 0).getCachedFormulaResultTypeEnum());
|
||||
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0, 0).getErrorCellValue());
|
||||
assertEquals(CellType.ERROR, getCell(sheet, 1, 0).getCachedFormulaResultType());
|
||||
assertEquals(CellType.ERROR, getCell(sheet, 1, 0).getCachedFormulaResultTypeEnum());
|
||||
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 1, 0).getErrorCellValue());
|
||||
assertEquals(CellType.ERROR, getCell(sheet, 0, 3).getCachedFormulaResultType());
|
||||
assertEquals(CellType.ERROR, getCell(sheet, 0, 3).getCachedFormulaResultTypeEnum());
|
||||
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0, 3).getErrorCellValue());
|
||||
|
||||
wb.close();
|
||||
|
@ -486,7 +486,7 @@ public final class TestXSSFFormulaParser {
|
||||
|
||||
for (Row row : xsheet) {
|
||||
for (Cell cell : row) {
|
||||
if (cell.getCellType() == CellType.FORMULA) {
|
||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
try {
|
||||
evaluator.evaluateFormulaCell(cell);
|
||||
} catch (Exception e) {
|
||||
|
@ -317,7 +317,7 @@ public class TestXSSFPivotTable extends TestCase {
|
||||
*/
|
||||
public void testAddDataColumnWithOffsetData() {
|
||||
offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1);
|
||||
assertEquals(CellType.NUMERIC, offsetOuterCell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, offsetOuterCell.getCellTypeEnum());
|
||||
|
||||
offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 0);
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public final class TestXSSFRow extends BaseTestXRow {
|
||||
assertSame("existing references to externObserverRow are still valid", externObserverRow, sheet2.getRow(0));
|
||||
|
||||
// Make sure copyRowFrom actually copied row (this is tested elsewhere)
|
||||
assertEquals(CellType.STRING, destRow.getCell(0).getCellType());
|
||||
assertEquals(CellType.STRING, destRow.getCell(0).getCellTypeEnum());
|
||||
assertEquals("hello", destRow.getCell(0).getStringCellValue());
|
||||
|
||||
// We don't want #REF! errors if we copy a row that contains cells that are referred to by other cells outside of copied region
|
||||
|
@ -1484,44 +1484,44 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
||||
|
||||
// Blank
|
||||
cell = CellUtil.getCell(destRow, col++);
|
||||
assertEquals("[Blank] C7 cell type", CellType.BLANK, cell.getCellType());
|
||||
assertEquals("[Blank] C7 cell type", CellType.BLANK, cell.getCellTypeEnum());
|
||||
|
||||
// Error
|
||||
cell = CellUtil.getCell(destRow, col++);
|
||||
assertEquals("[Error] D7 cell type", CellType.ERROR, cell.getCellType());
|
||||
assertEquals("[Error] D7 cell type", CellType.ERROR, cell.getCellTypeEnum());
|
||||
final FormulaError error = FormulaError.forInt(cell.getErrorCellValue());
|
||||
assertEquals("[Error] D7 cell value", FormulaError.NA, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here
|
||||
|
||||
// Date
|
||||
cell = CellUtil.getCell(destRow, col++);
|
||||
assertEquals("[Date] E7 cell type", CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals("[Date] E7 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
final Date date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 1).getTime();
|
||||
assertEquals("[Date] E7 cell value", date, cell.getDateCellValue());
|
||||
|
||||
// Boolean
|
||||
cell = CellUtil.getCell(destRow, col++);
|
||||
assertEquals("[Boolean] F7 cell type", CellType.BOOLEAN, cell.getCellType());
|
||||
assertEquals("[Boolean] F7 cell type", CellType.BOOLEAN, cell.getCellTypeEnum());
|
||||
assertEquals("[Boolean] F7 cell value", true, cell.getBooleanCellValue());
|
||||
|
||||
// String
|
||||
cell = CellUtil.getCell(destRow, col++);
|
||||
assertEquals("[String] G7 cell type", CellType.STRING, cell.getCellType());
|
||||
assertEquals("[String] G7 cell type", CellType.STRING, cell.getCellTypeEnum());
|
||||
assertEquals("[String] G7 cell value", "Hello", cell.getStringCellValue());
|
||||
|
||||
// Int
|
||||
cell = CellUtil.getCell(destRow, col++);
|
||||
assertEquals("[Int] H7 cell type", CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals("[Int] H7 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertEquals("[Int] H7 cell value", 15, (int) cell.getNumericCellValue());
|
||||
|
||||
// Float
|
||||
cell = CellUtil.getCell(destRow, col++);
|
||||
assertEquals("[Float] I7 cell type", CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals("[Float] I7 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertEquals("[Float] I7 cell value", 12.5, cell.getNumericCellValue(), FLOAT_PRECISION);
|
||||
|
||||
// Cell Formula
|
||||
cell = CellUtil.getCell(destRow, col++);
|
||||
assertEquals("J7", new CellReference(cell).formatAsString());
|
||||
assertEquals("[Cell Formula] J7 cell type", CellType.FORMULA, cell.getCellType());
|
||||
assertEquals("[Cell Formula] J7 cell type", CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("[Cell Formula] J7 cell formula", "5+2", cell.getCellFormula());
|
||||
System.out.println("Cell formula evaluation currently unsupported");
|
||||
|
||||
@ -1530,21 +1530,21 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
||||
cell = CellUtil.getCell(destRow, col++);
|
||||
assertEquals("K7", new CellReference(cell).formatAsString());
|
||||
assertEquals("[Cell Formula with Reference] K7 cell type",
|
||||
CellType.FORMULA, cell.getCellType());
|
||||
CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("[Cell Formula with Reference] K7 cell formula",
|
||||
"J7+H$2", cell.getCellFormula());
|
||||
|
||||
// Cell Formula with Reference spanning multiple rows
|
||||
cell = CellUtil.getCell(destRow, col++);
|
||||
assertEquals("[Cell Formula with Reference spanning multiple rows] L7 cell type",
|
||||
CellType.FORMULA, cell.getCellType());
|
||||
CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("[Cell Formula with Reference spanning multiple rows] L7 cell formula",
|
||||
"G7&\" \"&G8", cell.getCellFormula());
|
||||
|
||||
// Cell Formula with Reference spanning multiple rows
|
||||
cell = CellUtil.getCell(destRow, col++);
|
||||
assertEquals("[Cell Formula with Area Reference] M7 cell type",
|
||||
CellType.FORMULA, cell.getCellType());
|
||||
CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("[Cell Formula with Area Reference] M7 cell formula",
|
||||
"SUM(H7:I8)", cell.getCellFormula());
|
||||
|
||||
@ -1559,7 +1559,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
||||
|
||||
// Data Format
|
||||
cell = CellUtil.getCell(destRow, col++);
|
||||
assertEquals("[Data Format] O7 cell type;", CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals("[Data Format] O7 cell type;", CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertEquals("[Data Format] O7 cell value", 100.20, cell.getNumericCellValue(), FLOAT_PRECISION);
|
||||
//FIXME: currently fails
|
||||
final String moneyFormat = "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)";
|
||||
@ -1638,83 +1638,83 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
||||
// Blank
|
||||
col++;
|
||||
cell = CellUtil.getCell(destRow1, col);
|
||||
assertEquals("[Blank] C10 cell type", CellType.BLANK, cell.getCellType());
|
||||
assertEquals("[Blank] C10 cell type", CellType.BLANK, cell.getCellTypeEnum());
|
||||
|
||||
cell = CellUtil.getCell(destRow2, col);
|
||||
assertEquals("[Blank] C11 cell type", CellType.BLANK, cell.getCellType());
|
||||
assertEquals("[Blank] C11 cell type", CellType.BLANK, cell.getCellTypeEnum());
|
||||
|
||||
// Error
|
||||
col++;
|
||||
cell = CellUtil.getCell(destRow1, col);
|
||||
assertEquals("[Error] D10 cell type", CellType.ERROR, cell.getCellType());
|
||||
assertEquals("[Error] D10 cell type", CellType.ERROR, cell.getCellTypeEnum());
|
||||
FormulaError error = FormulaError.forInt(cell.getErrorCellValue());
|
||||
assertEquals("[Error] D10 cell value", FormulaError.NA, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here
|
||||
|
||||
cell = CellUtil.getCell(destRow2, col);
|
||||
assertEquals("[Error] D11 cell type", CellType.ERROR, cell.getCellType());
|
||||
assertEquals("[Error] D11 cell type", CellType.ERROR, cell.getCellTypeEnum());
|
||||
error = FormulaError.forInt(cell.getErrorCellValue());
|
||||
assertEquals("[Error] D11 cell value", FormulaError.NAME, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here
|
||||
|
||||
// Date
|
||||
col++;
|
||||
cell = CellUtil.getCell(destRow1, col);
|
||||
assertEquals("[Date] E10 cell type", CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals("[Date] E10 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
Date date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 1).getTime();
|
||||
assertEquals("[Date] E10 cell value", date, cell.getDateCellValue());
|
||||
|
||||
cell = CellUtil.getCell(destRow2, col);
|
||||
assertEquals("[Date] E11 cell type", CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals("[Date] E11 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 2).getTime();
|
||||
assertEquals("[Date] E11 cell value", date, cell.getDateCellValue());
|
||||
|
||||
// Boolean
|
||||
col++;
|
||||
cell = CellUtil.getCell(destRow1, col);
|
||||
assertEquals("[Boolean] F10 cell type", CellType.BOOLEAN, cell.getCellType());
|
||||
assertEquals("[Boolean] F10 cell type", CellType.BOOLEAN, cell.getCellTypeEnum());
|
||||
assertEquals("[Boolean] F10 cell value", true, cell.getBooleanCellValue());
|
||||
|
||||
cell = CellUtil.getCell(destRow2, col);
|
||||
assertEquals("[Boolean] F11 cell type", CellType.BOOLEAN, cell.getCellType());
|
||||
assertEquals("[Boolean] F11 cell type", CellType.BOOLEAN, cell.getCellTypeEnum());
|
||||
assertEquals("[Boolean] F11 cell value", false, cell.getBooleanCellValue());
|
||||
|
||||
// String
|
||||
col++;
|
||||
cell = CellUtil.getCell(destRow1, col);
|
||||
assertEquals("[String] G10 cell type", CellType.STRING, cell.getCellType());
|
||||
assertEquals("[String] G10 cell type", CellType.STRING, cell.getCellTypeEnum());
|
||||
assertEquals("[String] G10 cell value", "Hello", cell.getStringCellValue());
|
||||
|
||||
cell = CellUtil.getCell(destRow2, col);
|
||||
assertEquals("[String] G11 cell type", CellType.STRING, cell.getCellType());
|
||||
assertEquals("[String] G11 cell type", CellType.STRING, cell.getCellTypeEnum());
|
||||
assertEquals("[String] G11 cell value", "World", cell.getStringCellValue());
|
||||
|
||||
// Int
|
||||
col++;
|
||||
cell = CellUtil.getCell(destRow1, col);
|
||||
assertEquals("[Int] H10 cell type", CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals("[Int] H10 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertEquals("[Int] H10 cell value", 15, (int) cell.getNumericCellValue());
|
||||
|
||||
cell = CellUtil.getCell(destRow2, col);
|
||||
assertEquals("[Int] H11 cell type", CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals("[Int] H11 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertEquals("[Int] H11 cell value", 42, (int) cell.getNumericCellValue());
|
||||
|
||||
// Float
|
||||
col++;
|
||||
cell = CellUtil.getCell(destRow1, col);
|
||||
assertEquals("[Float] I10 cell type", CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals("[Float] I10 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertEquals("[Float] I10 cell value", 12.5, cell.getNumericCellValue(), FLOAT_PRECISION);
|
||||
|
||||
cell = CellUtil.getCell(destRow2, col);
|
||||
assertEquals("[Float] I11 cell type", CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals("[Float] I11 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertEquals("[Float] I11 cell value", 5.5, cell.getNumericCellValue(), FLOAT_PRECISION);
|
||||
|
||||
// Cell Formula
|
||||
col++;
|
||||
cell = CellUtil.getCell(destRow1, col);
|
||||
assertEquals("[Cell Formula] J10 cell type", CellType.FORMULA, cell.getCellType());
|
||||
assertEquals("[Cell Formula] J10 cell type", CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("[Cell Formula] J10 cell formula", "5+2", cell.getCellFormula());
|
||||
|
||||
cell = CellUtil.getCell(destRow2, col);
|
||||
assertEquals("[Cell Formula] J11 cell type", CellType.FORMULA, cell.getCellType());
|
||||
assertEquals("[Cell Formula] J11 cell type", CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("[Cell Formula] J11 cell formula", "6+18", cell.getCellFormula());
|
||||
|
||||
// Cell Formula with Reference
|
||||
@ -1722,25 +1722,25 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
||||
// Formula row references should be adjusted by destRowNum-srcRowNum
|
||||
cell = CellUtil.getCell(destRow1, col);
|
||||
assertEquals("[Cell Formula with Reference] K10 cell type",
|
||||
CellType.FORMULA, cell.getCellType());
|
||||
CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("[Cell Formula with Reference] K10 cell formula",
|
||||
"J10+H$2", cell.getCellFormula());
|
||||
|
||||
cell = CellUtil.getCell(destRow2, col);
|
||||
assertEquals("[Cell Formula with Reference] K11 cell type", CellType.FORMULA, cell.getCellType());
|
||||
assertEquals("[Cell Formula with Reference] K11 cell type", CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("[Cell Formula with Reference] K11 cell formula", "J11+H$2", cell.getCellFormula());
|
||||
|
||||
// Cell Formula with Reference spanning multiple rows
|
||||
col++;
|
||||
cell = CellUtil.getCell(destRow1, col);
|
||||
assertEquals("[Cell Formula with Reference spanning multiple rows] L10 cell type",
|
||||
CellType.FORMULA, cell.getCellType());
|
||||
CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("[Cell Formula with Reference spanning multiple rows] L10 cell formula",
|
||||
"G10&\" \"&G11", cell.getCellFormula());
|
||||
|
||||
cell = CellUtil.getCell(destRow2, col);
|
||||
assertEquals("[Cell Formula with Reference spanning multiple rows] L11 cell type",
|
||||
CellType.FORMULA, cell.getCellType());
|
||||
CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("[Cell Formula with Reference spanning multiple rows] L11 cell formula",
|
||||
"G11&\" \"&G12", cell.getCellFormula());
|
||||
|
||||
@ -1748,13 +1748,13 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
||||
col++;
|
||||
cell = CellUtil.getCell(destRow1, col);
|
||||
assertEquals("[Cell Formula with Area Reference] M10 cell type",
|
||||
CellType.FORMULA, cell.getCellType());
|
||||
CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("[Cell Formula with Area Reference] M10 cell formula",
|
||||
"SUM(H10:I11)", cell.getCellFormula());
|
||||
|
||||
cell = CellUtil.getCell(destRow2, col);
|
||||
assertEquals("[Cell Formula with Area Reference] M11 cell type",
|
||||
CellType.FORMULA, cell.getCellType());
|
||||
CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("[Cell Formula with Area Reference] M11 cell formula",
|
||||
"SUM($H$3:I10)", cell.getCellFormula()); //Also acceptable: SUM($H10:I$3), but this AreaReference isn't in ascending order
|
||||
|
||||
@ -1776,7 +1776,7 @@ public final class TestXSSFSheet extends BaseTestXSheet {
|
||||
// Data Format
|
||||
col++;
|
||||
cell = CellUtil.getCell(destRow2, col);
|
||||
assertEquals("[Data Format] O10 cell type", CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals("[Data Format] O10 cell type", CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertEquals("[Data Format] O10 cell value", 100.20, cell.getNumericCellValue(), FLOAT_PRECISION);
|
||||
final String moneyFormat = "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)";
|
||||
assertEquals("[Data Format] O10 cell data format", moneyFormat, cell.getCellStyle().getDataFormatString());
|
||||
|
@ -117,7 +117,7 @@ public final class TestXSSFSheetShiftRows extends BaseTestSheetShiftRows {
|
||||
return;
|
||||
}
|
||||
Cell readCell = readRow.getCell(0);
|
||||
if(readCell.getCellType() == CellType.NUMERIC) {
|
||||
if(readCell.getCellTypeEnum() == CellType.NUMERIC) {
|
||||
assertEquals(expect, Double.toString(readCell.getNumericCellValue()));
|
||||
} else {
|
||||
assertEquals(expect, readCell.getStringCellValue());
|
||||
|
@ -121,14 +121,14 @@ public abstract class AbstractExcelConverter
|
||||
protected boolean isTextEmpty( HSSFCell cell )
|
||||
{
|
||||
final String value;
|
||||
switch ( cell.getCellType() )
|
||||
switch ( cell.getCellTypeEnum() )
|
||||
{
|
||||
case STRING:
|
||||
// XXX: enrich
|
||||
value = cell.getRichStringCellValue().getString();
|
||||
break;
|
||||
case FORMULA:
|
||||
switch ( cell.getCachedFormulaResultType() )
|
||||
switch ( cell.getCachedFormulaResultTypeEnum() )
|
||||
{
|
||||
case STRING:
|
||||
HSSFRichTextString str = cell.getRichStringCellValue();
|
||||
|
@ -207,14 +207,14 @@ public class ExcelToFoConverter extends AbstractExcelConverter
|
||||
final HSSFCellStyle cellStyle = cell.getCellStyle();
|
||||
|
||||
String value;
|
||||
switch ( cell.getCellType() )
|
||||
switch ( cell.getCellTypeEnum() )
|
||||
{
|
||||
case STRING:
|
||||
// XXX: enrich
|
||||
value = cell.getRichStringCellValue().getString();
|
||||
break;
|
||||
case FORMULA:
|
||||
switch ( cell.getCachedFormulaResultType() )
|
||||
switch ( cell.getCachedFormulaResultTypeEnum() )
|
||||
{
|
||||
case STRING:
|
||||
HSSFRichTextString str = cell.getRichStringCellValue();
|
||||
@ -243,7 +243,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
|
||||
logger.log(
|
||||
POILogger.WARN,
|
||||
"Unexpected cell cachedFormulaResultType ("
|
||||
+ cell.getCachedFormulaResultType() + ")" );
|
||||
+ cell.getCachedFormulaResultTypeEnum() + ")" );
|
||||
value = ExcelToHtmlUtils.EMPTY;
|
||||
break;
|
||||
}
|
||||
@ -262,7 +262,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
|
||||
break;
|
||||
default:
|
||||
logger.log( POILogger.WARN,
|
||||
"Unexpected cell type (" + cell.getCellType() + ")" );
|
||||
"Unexpected cell type (" + cell.getCellTypeEnum() + ")" );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -294,14 +294,14 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter
|
||||
final HSSFCellStyle cellStyle = cell.getCellStyle();
|
||||
|
||||
String value;
|
||||
switch ( cell.getCellType() )
|
||||
switch ( cell.getCellTypeEnum() )
|
||||
{
|
||||
case STRING:
|
||||
// XXX: enrich
|
||||
value = cell.getRichStringCellValue().getString();
|
||||
break;
|
||||
case FORMULA:
|
||||
switch ( cell.getCachedFormulaResultType() )
|
||||
switch ( cell.getCachedFormulaResultTypeEnum() )
|
||||
{
|
||||
case STRING:
|
||||
HSSFRichTextString str = cell.getRichStringCellValue();
|
||||
@ -330,7 +330,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter
|
||||
logger.log(
|
||||
POILogger.WARN,
|
||||
"Unexpected cell cachedFormulaResultType ("
|
||||
+ cell.getCachedFormulaResultType() + ")" );
|
||||
+ cell.getCachedFormulaResultTypeEnum() + ")" );
|
||||
value = ExcelToHtmlUtils.EMPTY;
|
||||
break;
|
||||
}
|
||||
@ -349,7 +349,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter
|
||||
break;
|
||||
default:
|
||||
logger.log( POILogger.WARN,
|
||||
"Unexpected cell type (" + cell.getCellType() + ")" );
|
||||
"Unexpected cell type (" + cell.getCellTypeEnum() + ")" );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ public final class TestRVA {
|
||||
break;
|
||||
}
|
||||
HSSFCell cell = row.getCell(0);
|
||||
if (cell == null || cell.getCellType() == CellType.BLANK) {
|
||||
if (cell == null || cell.getCellTypeEnum() == CellType.BLANK) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public final class TestBug42464 {
|
||||
Iterator<Cell> it = row.cellIterator();
|
||||
while(it.hasNext()) {
|
||||
HSSFCell cell = (HSSFCell)it.next();
|
||||
if(cell.getCellType() != CellType.FORMULA) {
|
||||
if(cell.getCellTypeEnum() != CellType.FORMULA) {
|
||||
continue;
|
||||
}
|
||||
FormulaRecordAggregate record = (FormulaRecordAggregate) cell.getCellValueRecord();
|
||||
|
@ -469,7 +469,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
HSSFRow row = sheet.getRow(i);
|
||||
if (row != null) {
|
||||
HSSFCell cell = row .getCell(0);
|
||||
assertEquals(CellType.STRING, cell.getCellType());
|
||||
assertEquals(CellType.STRING, cell.getCellTypeEnum());
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@ -1167,13 +1167,13 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
}
|
||||
|
||||
private static void confirmCachedValue(double expectedValue, HSSFCell cell) {
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(expectedValue, cell.getNumericCellValue(), 0.0);
|
||||
}
|
||||
private static void confirmCachedValue(String expectedValue, HSSFCell cell) {
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.STRING, cell.getCachedFormulaResultType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals(CellType.STRING, cell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(expectedValue, cell.getRichStringCellValue().getString());
|
||||
}
|
||||
|
||||
@ -1288,7 +1288,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
s = wb.getSheet("OneVariable Table Completed");
|
||||
r = s.getRow(3);
|
||||
c = r.getCell(4);
|
||||
assertEquals(CellType.FORMULA, c.getCellType());
|
||||
assertEquals(CellType.FORMULA, c.getCellTypeEnum());
|
||||
|
||||
// TODO - check the formula once tables and
|
||||
// arrays are properly supported
|
||||
@ -1298,7 +1298,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
s = wb.getSheet("TwoVariable Table Example");
|
||||
r = s.getRow(3);
|
||||
c = r.getCell(4);
|
||||
assertEquals(CellType.FORMULA, c.getCellType());
|
||||
assertEquals(CellType.FORMULA, c.getCellTypeEnum());
|
||||
|
||||
// TODO - check the formula once tables and
|
||||
// arrays are properly supported
|
||||
@ -1824,26 +1824,26 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
HSSFRow row;
|
||||
|
||||
row = s.getRow(0);
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1).getCellType());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1).getCellTypeEnum());
|
||||
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
|
||||
|
||||
row = s.getRow(1);
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
|
||||
assertEquals("B1", row.getCell(1).getCellFormula());
|
||||
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
|
||||
|
||||
row = s.getRow(2);
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
|
||||
assertEquals("Sheet1!B1", row.getCell(1).getCellFormula());
|
||||
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
|
||||
|
||||
row = s.getRow(3);
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
|
||||
assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula());
|
||||
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
|
||||
|
||||
row = s.getRow(4);
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
|
||||
assertEquals("'[$http://gagravarr.org/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula());
|
||||
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
|
||||
|
||||
@ -1864,21 +1864,21 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
s = wb2.getSheetAt(0);
|
||||
|
||||
row = s.getRow(0);
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1).getCellType());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1).getCellTypeEnum());
|
||||
assertEquals(112.0, row.getCell(1).getNumericCellValue(),0);
|
||||
|
||||
row = s.getRow(1);
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
|
||||
assertEquals("B1", row.getCell(1).getCellFormula());
|
||||
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
|
||||
|
||||
row = s.getRow(2);
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
|
||||
assertEquals("Sheet1!B1", row.getCell(1).getCellFormula());
|
||||
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
|
||||
|
||||
row = s.getRow(3);
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
|
||||
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
|
||||
assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula());
|
||||
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
|
||||
|
||||
@ -2755,13 +2755,13 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
}
|
||||
|
||||
private void assertFormula(Workbook wb, Cell intF, String expectedFormula, String expectedResultOrNull) {
|
||||
assertEquals(CellType.FORMULA, intF.getCellType());
|
||||
assertEquals(CellType.FORMULA, intF.getCellTypeEnum());
|
||||
if (null == expectedResultOrNull) {
|
||||
assertEquals(CellType.ERROR, intF.getCachedFormulaResultType());
|
||||
assertEquals(CellType.ERROR, intF.getCachedFormulaResultTypeEnum());
|
||||
expectedResultOrNull = "#VALUE!";
|
||||
}
|
||||
else {
|
||||
assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultType());
|
||||
assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultTypeEnum());
|
||||
}
|
||||
|
||||
assertEquals(expectedFormula, intF.getCellFormula());
|
||||
@ -2987,12 +2987,12 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
Sheet sheet = wb.getSheetAt(0);
|
||||
Row row = sheet.getRow(0);
|
||||
Cell cell = row.getCell(0);
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("IF(TRUE,\"\",\"\")", cell.getCellFormula());
|
||||
assertEquals("", cell.getStringCellValue());
|
||||
cell.setCellType(CellType.STRING);
|
||||
|
||||
assertEquals(CellType.BLANK, cell.getCellType());
|
||||
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
|
||||
try {
|
||||
assertNull(cell.getCellFormula());
|
||||
fail("Should throw an exception here");
|
||||
|
@ -436,7 +436,7 @@ public final class TestCellStyle extends TestCase {
|
||||
|
||||
Cell cell = row.getCell(idxCell);
|
||||
cell.getCellStyle().getDataFormatString();
|
||||
if (cell.getCellType() == CellType.NUMERIC) {
|
||||
if (cell.getCellTypeEnum() == CellType.NUMERIC) {
|
||||
boolean isDate = HSSFDateUtil.isCellDateFormatted(cell);
|
||||
if (idxCell > 0 && isDate) {
|
||||
fail("cell " + idxCell + " is not a date: " + idxCell.toString());
|
||||
|
@ -51,7 +51,7 @@ public class TestExternalReferenceChange extends TestCase {
|
||||
HSSFSheet lSheet = mainWorkbook.getSheetAt(0);
|
||||
HSSFCell lA1Cell = lSheet.getRow(0).getCell(0);
|
||||
|
||||
assertEquals(CellType.FORMULA, lA1Cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum());
|
||||
|
||||
HSSFFormulaEvaluator lMainWorkbookEvaluator = new HSSFFormulaEvaluator(mainWorkbook);
|
||||
HSSFFormulaEvaluator lSourceEvaluator = new HSSFFormulaEvaluator(sourceWorkbook);
|
||||
|
@ -566,7 +566,7 @@ public final class TestFormulaEvaluatorBugs {
|
||||
}
|
||||
}
|
||||
private Ptg[] getPtgs(HSSFCell cell) {
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals(FormulaRecordAggregate.class, cell.getCellValueRecord().getClass());
|
||||
FormulaRecordAggregate agg = (FormulaRecordAggregate)cell.getCellValueRecord();
|
||||
FormulaRecord rec = agg.getFormulaRecord();
|
||||
|
@ -77,7 +77,7 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
|
||||
|
||||
for(Iterator cit = r.cellIterator(); cit.hasNext();) {
|
||||
HSSFCell c = (HSSFCell)cit.next();
|
||||
if(c.getCellType() == CellType.FORMULA) {
|
||||
if(c.getCellTypeEnum() == CellType.FORMULA) {
|
||||
evaluator.evaluateFormulaCell(c);
|
||||
|
||||
// For testing - all should be numeric
|
||||
@ -90,15 +90,15 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
|
||||
// Check now as expected
|
||||
assertEquals(55.7, wb.getSheetAt(0).getRow(0).getCell(2).getNumericCellValue(), 0);
|
||||
assertEquals("SUM(A1:B1)", wb.getSheetAt(0).getRow(0).getCell(2).getCellFormula());
|
||||
assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(0).getCell(2).getCellType());
|
||||
assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(0).getCell(2).getCellTypeEnum());
|
||||
|
||||
assertEquals(-4.6, wb.getSheetAt(0).getRow(1).getCell(2).getNumericCellValue(), 0);
|
||||
assertEquals("SUM(A2:B2)", wb.getSheetAt(0).getRow(1).getCell(2).getCellFormula());
|
||||
assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(1).getCell(2).getCellType());
|
||||
assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(1).getCell(2).getCellTypeEnum());
|
||||
|
||||
assertEquals(22.3, wb.getSheetAt(1).getRow(0).getCell(0).getNumericCellValue(), 0);
|
||||
assertEquals("'S1'!A1", wb.getSheetAt(1).getRow(0).getCell(0).getCellFormula());
|
||||
assertEquals(CellType.FORMULA, wb.getSheetAt(1).getRow(0).getCell(0).getCellType());
|
||||
assertEquals(CellType.FORMULA, wb.getSheetAt(1).getRow(0).getCell(0).getCellTypeEnum());
|
||||
|
||||
|
||||
// Now do the alternate call, which zaps the formulas
|
||||
@ -112,7 +112,7 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
|
||||
|
||||
for(Iterator cit = r.cellIterator(); cit.hasNext();) {
|
||||
HSSFCell c = (HSSFCell)cit.next();
|
||||
if(c.getCellType() == CellType.FORMULA) {
|
||||
if(c.getCellTypeEnum() == CellType.FORMULA) {
|
||||
evaluator.evaluateInCell(c);
|
||||
}
|
||||
}
|
||||
@ -120,12 +120,12 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
|
||||
}
|
||||
|
||||
assertEquals(55.7, wb.getSheetAt(0).getRow(0).getCell(2).getNumericCellValue(), 0);
|
||||
assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(0).getCell(2).getCellType());
|
||||
assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(0).getCell(2).getCellTypeEnum());
|
||||
|
||||
assertEquals(-4.6, wb.getSheetAt(0).getRow(1).getCell(2).getNumericCellValue(), 0);
|
||||
assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(1).getCell(2).getCellType());
|
||||
assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(1).getCell(2).getCellTypeEnum());
|
||||
|
||||
assertEquals(22.3, wb.getSheetAt(1).getRow(0).getCell(0).getNumericCellValue(), 0);
|
||||
assertEquals(CellType.NUMERIC, wb.getSheetAt(1).getRow(0).getCell(0).getCellType());
|
||||
assertEquals(CellType.NUMERIC, wb.getSheetAt(1).getRow(0).getCell(0).getCellTypeEnum());
|
||||
}
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ public final class TestHSSFCell extends BaseTestCell {
|
||||
assertEquals(wb.getWorkbook(), cell.getBoundWorkbook());
|
||||
|
||||
try {
|
||||
cell.getCachedFormulaResultType();
|
||||
cell.getCachedFormulaResultTypeEnum();
|
||||
fail("Should catch exception");
|
||||
} catch (IllegalStateException e) {
|
||||
// expected here
|
||||
|
@ -384,7 +384,7 @@ public final class TestHSSFDataFormatter {
|
||||
HSSFRow row = sheet.getRow(0);
|
||||
HSSFCell cellA1 = row.getCell(0);
|
||||
|
||||
assertEquals(CellType.NUMERIC, cellA1.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cellA1.getCellTypeEnum());
|
||||
assertEquals(2345.0, cellA1.getNumericCellValue(), 0.0001);
|
||||
assertEquals("@", cellA1.getCellStyle().getDataFormatString());
|
||||
|
||||
|
@ -199,8 +199,8 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
|
||||
|
||||
// VLookup on a name in another file
|
||||
cell = wb1.getSheetAt(0).getRow(1).getCell(2);
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(12.30, cell.getNumericCellValue(), 0.0001);
|
||||
// WARNING - this is wrong!
|
||||
// The file name should be showing, but bug #45970 is fixed
|
||||
@ -210,8 +210,8 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
|
||||
|
||||
// Simple reference to a name in another file
|
||||
cell = wb1.getSheetAt(0).getRow(1).getCell(4);
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(36.90, cell.getNumericCellValue(), 0.0001);
|
||||
// TODO Correct this!
|
||||
// The file name should be shown too, see bug #56742
|
||||
@ -237,14 +237,14 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
|
||||
|
||||
// Re-check VLOOKUP one
|
||||
cell = wb1.getSheetAt(0).getRow(1).getCell(2);
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(12.30, cell.getNumericCellValue(), 0.0001);
|
||||
|
||||
// Re-check ref one
|
||||
cell = wb1.getSheetAt(0).getRow(1).getCell(4);
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(36.90, cell.getNumericCellValue(), 0.0001);
|
||||
|
||||
|
||||
|
@ -392,7 +392,7 @@ public final class TestWorkbook {
|
||||
HSSFSheet s = wb.getSheetAt(0);
|
||||
HSSFCell c = s.getRow(0).getCell(0);
|
||||
|
||||
assertEquals(CellType.NUMERIC, c.getCellType());
|
||||
assertEquals(CellType.NUMERIC, c.getCellTypeEnum());
|
||||
|
||||
wb.close();
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class TestMissingWorkbook extends TestCase {
|
||||
Row lARow = lSheet.getRow(0);
|
||||
Cell lA1Cell = lARow.getCell(0);
|
||||
|
||||
assertEquals(CellType.FORMULA, lA1Cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum());
|
||||
try {
|
||||
evaluator.evaluateFormulaCell(lA1Cell);
|
||||
fail("Missing external workbook reference exception expected!");
|
||||
@ -82,9 +82,9 @@ public class TestMissingWorkbook extends TestCase {
|
||||
Cell lB1Cell = lSheet.getRow(1).getCell(0);
|
||||
Cell lC1Cell = lSheet.getRow(2).getCell(0);
|
||||
|
||||
assertEquals(CellType.FORMULA, lA1Cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, lB1Cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, lC1Cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum());
|
||||
assertEquals(CellType.FORMULA, lB1Cell.getCellTypeEnum());
|
||||
assertEquals(CellType.FORMULA, lC1Cell.getCellTypeEnum());
|
||||
|
||||
// Check cached values
|
||||
assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d);
|
||||
@ -111,9 +111,9 @@ public class TestMissingWorkbook extends TestCase {
|
||||
Cell lB1Cell = lSheet.getRow(1).getCell(0);
|
||||
Cell lC1Cell = lSheet.getRow(2).getCell(0);
|
||||
|
||||
assertEquals(CellType.FORMULA, lA1Cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, lB1Cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, lC1Cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum());
|
||||
assertEquals(CellType.FORMULA, lB1Cell.getCellTypeEnum());
|
||||
assertEquals(CellType.FORMULA, lC1Cell.getCellTypeEnum());
|
||||
|
||||
FormulaEvaluator lMainWorkbookEvaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator();
|
||||
FormulaEvaluator lSourceEvaluator = sourceWorkbook.getCreationHelper().createFormulaEvaluator();
|
||||
|
@ -365,7 +365,7 @@ public class TestWorkbookEvaluator {
|
||||
CellValue result = eval.evaluate(D1);
|
||||
|
||||
// Call should not modify the contents
|
||||
assertEquals(CellType.FORMULA, D1.getCellType());
|
||||
assertEquals(CellType.FORMULA, D1.getCellTypeEnum());
|
||||
assertEquals(expectedFormula, D1.getCellFormula());
|
||||
|
||||
assertEquals(CellType.NUMERIC, result.getCellType());
|
||||
@ -514,10 +514,10 @@ public class TestWorkbookEvaluator {
|
||||
CellType resultCellType = eval.evaluateFormulaCell(D1);
|
||||
|
||||
// Call should modify the contents, but leave the formula intact
|
||||
assertEquals(CellType.FORMULA, D1.getCellType());
|
||||
assertEquals(CellType.FORMULA, D1.getCellTypeEnum());
|
||||
assertEquals(expectedFormula, D1.getCellFormula());
|
||||
assertEquals(CellType.NUMERIC, resultCellType);
|
||||
assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultType());
|
||||
assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON);
|
||||
|
||||
testIFEqualsFormulaEvaluation_teardown(wb);
|
||||
@ -537,7 +537,7 @@ public class TestWorkbookEvaluator {
|
||||
D1.getCellFormula();
|
||||
fail("cell formula should be overwritten with formula result");
|
||||
} catch (final IllegalStateException expected) { }
|
||||
assertEquals(CellType.NUMERIC, D1.getCellType());
|
||||
assertEquals(CellType.NUMERIC, D1.getCellTypeEnum());
|
||||
assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON);
|
||||
|
||||
testIFEqualsFormulaEvaluation_teardown(wb);
|
||||
@ -552,10 +552,10 @@ public class TestWorkbookEvaluator {
|
||||
eval.evaluateAll();
|
||||
|
||||
// Call should modify the contents
|
||||
assertEquals(CellType.FORMULA, D1.getCellType());
|
||||
assertEquals(CellType.FORMULA, D1.getCellTypeEnum());
|
||||
assertEquals(expectedFormula, D1.getCellFormula());
|
||||
|
||||
assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultType());
|
||||
assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON);
|
||||
|
||||
testIFEqualsFormulaEvaluation_teardown(wb);
|
||||
@ -569,11 +569,11 @@ public class TestWorkbookEvaluator {
|
||||
HSSFFormulaEvaluator.evaluateAllFormulaCells(wb);
|
||||
|
||||
// Call should modify the contents
|
||||
assertEquals(CellType.FORMULA, D1.getCellType());
|
||||
assertEquals(CellType.FORMULA, D1.getCellTypeEnum());
|
||||
// whitespace gets deleted because formula is parsed and re-rendered
|
||||
assertEquals(expectedFormula, D1.getCellFormula());
|
||||
|
||||
assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultType());
|
||||
assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON);
|
||||
|
||||
testIFEqualsFormulaEvaluation_teardown(wb);
|
||||
|
@ -131,7 +131,7 @@ public class TestRandBetween extends TestCase {
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
|
||||
|
||||
|
||||
@ -141,7 +141,7 @@ public class TestRandBetween extends TestCase {
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
|
||||
|
||||
// Check case where both inputs are of wrong type
|
||||
@ -150,7 +150,7 @@ public class TestRandBetween extends TestCase {
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
|
||||
|
||||
}
|
||||
@ -166,14 +166,14 @@ public class TestRandBetween extends TestCase {
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
|
||||
bottomValueCell.setCellValue(1);
|
||||
topValueCell.setCellType(CellType.BLANK);
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public final class TestYearFracCalculatorFromSpreadsheet {
|
||||
HSSFRow row = (HSSFRow) rowIterator.next();
|
||||
|
||||
HSSFCell cell = row.getCell(SS.YEARFRAC_FORMULA_COLUMN);
|
||||
if (cell == null || cell.getCellType() != CellType.FORMULA) {
|
||||
if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
|
||||
continue;
|
||||
}
|
||||
processRow(row, cell, formulaEvaluator);
|
||||
|
@ -174,7 +174,7 @@ public final class TestFormulasFromSpreadsheet {
|
||||
// iterate across the row for all the evaluation cases
|
||||
for (int colnum=SS.COLUMN_INDEX_FIRST_TEST_VALUE; colnum < endcolnum; colnum++) {
|
||||
Cell c = formulasRow.getCell(colnum);
|
||||
if (c == null || c.getCellType() != CellType.FORMULA) {
|
||||
if (c == null || c.getCellTypeEnum() != CellType.FORMULA) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ public final class TestFormulasFromSpreadsheet {
|
||||
assertNotNull(msg + " - Bad setup data expected value is null", expValue);
|
||||
assertNotNull(msg + " - actual value was null", actValue);
|
||||
|
||||
final CellType cellType = expValue.getCellType();
|
||||
final CellType cellType = expValue.getCellTypeEnum();
|
||||
switch (cellType) {
|
||||
case BLANK:
|
||||
assertEquals(msg, CellType.BLANK, actValue.getCellType());
|
||||
@ -228,14 +228,14 @@ public final class TestFormulasFromSpreadsheet {
|
||||
System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name");
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.BLANK) {
|
||||
if(cell.getCellTypeEnum() == CellType.BLANK) {
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.STRING) {
|
||||
if(cell.getCellTypeEnum() == CellType.STRING) {
|
||||
return cell.getRichStringCellValue().getString();
|
||||
}
|
||||
|
||||
throw new AssertionFailedError("Bad cell type for 'function name' column: ("
|
||||
+ cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
|
||||
+ cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")");
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ public final class TestMultiSheetEval extends TestCase {
|
||||
throw new AssertionFailedError(msg + " - actual value was null");
|
||||
}
|
||||
|
||||
final CellType cellType = expected.getCellType();
|
||||
final CellType cellType = expected.getCellTypeEnum();
|
||||
|
||||
switch (cellType) {
|
||||
case BLANK:
|
||||
@ -231,7 +231,7 @@ public final class TestMultiSheetEval extends TestCase {
|
||||
int result = Result.NO_EVALUATIONS_FOUND; // so far
|
||||
|
||||
Cell c = formulasRow.getCell(SS.COLUMN_INDEX_ACTUAL_VALUE);
|
||||
if (c == null || c.getCellType() != CellType.FORMULA) {
|
||||
if (c == null || c.getCellTypeEnum() != CellType.FORMULA) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -300,15 +300,15 @@ public final class TestMultiSheetEval extends TestCase {
|
||||
System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name");
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.BLANK) {
|
||||
if(cell.getCellTypeEnum() == CellType.BLANK) {
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.STRING) {
|
||||
if(cell.getCellTypeEnum() == CellType.STRING) {
|
||||
return cell.getRichStringCellValue().getString();
|
||||
}
|
||||
|
||||
throw new AssertionFailedError("Bad cell type for 'function name' column: ("
|
||||
+ cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
|
||||
+ cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")");
|
||||
}
|
||||
/**
|
||||
* @return <code>null</code> if cell is missing, empty or blank
|
||||
@ -323,15 +323,15 @@ public final class TestMultiSheetEval extends TestCase {
|
||||
System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_TEST_NAME + ", can't figure out test name");
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.BLANK) {
|
||||
if(cell.getCellTypeEnum() == CellType.BLANK) {
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.STRING) {
|
||||
if(cell.getCellTypeEnum() == CellType.STRING) {
|
||||
return cell.getRichStringCellValue().getString();
|
||||
}
|
||||
|
||||
throw new AssertionFailedError("Bad cell type for 'test name' column: ("
|
||||
+ cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
|
||||
+ cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
|
||||
currentGroupComment = newMarkerValue;
|
||||
}
|
||||
HSSFCell evalCell = r.getCell(SS.COLUMN_INDEX_EVALUATION);
|
||||
if (evalCell == null || evalCell.getCellType() != CellType.FORMULA) {
|
||||
if (evalCell == null || evalCell.getCellTypeEnum() != CellType.FORMULA) {
|
||||
continue;
|
||||
}
|
||||
String rowComment = getCellTextValue(r, SS.COLUMN_ROW_COMMENT, "row comment");
|
||||
@ -153,7 +153,7 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
|
||||
assertNotNull(msg + " - Bad setup data expected value is null", expectedCell);
|
||||
assertNotNull(msg + " - actual value was null", actualValue);
|
||||
|
||||
if (expectedCell.getCellType() == CellType.ERROR) {
|
||||
if (expectedCell.getCellTypeEnum() == CellType.ERROR) {
|
||||
int expectedErrorCode = expectedCell.getErrorCellValue();
|
||||
assertEquals(msg, CellType.ERROR, actualValue.getCellType());
|
||||
assertEquals(msg, ErrorEval.getText(expectedErrorCode), actualValue.formatAsString());
|
||||
@ -167,9 +167,9 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
|
||||
assertNotEquals(msg, formatValue(expectedCell), ErrorEval.getText(actualValue.getErrorValue()));
|
||||
|
||||
// wrong type error
|
||||
assertEquals(msg, expectedCell.getCellType(), actualValue.getCellType());
|
||||
assertEquals(msg, expectedCell.getCellTypeEnum(), actualValue.getCellType());
|
||||
|
||||
final CellType expectedCellType = expectedCell.getCellType();
|
||||
final CellType expectedCellType = expectedCell.getCellTypeEnum();
|
||||
switch (expectedCellType) {
|
||||
case BOOLEAN:
|
||||
assertEquals(msg, expectedCell.getBooleanCellValue(), actualValue.getBooleanValue());
|
||||
@ -212,25 +212,25 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
|
||||
if(cell == null) {
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.BLANK) {
|
||||
if(cell.getCellTypeEnum() == CellType.BLANK) {
|
||||
return null;
|
||||
}
|
||||
if(cell.getCellType() == CellType.STRING) {
|
||||
if(cell.getCellTypeEnum() == CellType.STRING) {
|
||||
return cell.getRichStringCellValue().getString();
|
||||
}
|
||||
|
||||
fail("Bad cell type for '" + columnName + "' column: ("
|
||||
+ cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
|
||||
+ cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")");
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String formatValue(HSSFCell expecedCell) {
|
||||
switch (expecedCell.getCellType()) {
|
||||
switch (expecedCell.getCellTypeEnum()) {
|
||||
case BLANK: return "<blank>";
|
||||
case BOOLEAN: return Boolean.toString(expecedCell.getBooleanCellValue());
|
||||
case NUMERIC: return Double.toString(expecedCell.getNumericCellValue());
|
||||
case STRING: return expecedCell.getRichStringCellValue().getString();
|
||||
default: fail("Unexpected cell type of expected value (" + expecedCell.getCellType() + ")");
|
||||
default: fail("Unexpected cell type of expected value (" + expecedCell.getCellTypeEnum() + ")");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -505,9 +505,9 @@ public final class TestCountFuncs extends TestCase {
|
||||
for (int rowIx=7; rowIx<=12; rowIx++) {
|
||||
HSSFRow row = sheet1.getRow(rowIx-1);
|
||||
HSSFCell cellA = row.getCell(0); // cell containing a formula with COUNTIF
|
||||
assertEquals(CellType.FORMULA, cellA.getCellType());
|
||||
assertEquals(CellType.FORMULA, cellA.getCellTypeEnum());
|
||||
HSSFCell cellC = row.getCell(2); // cell with a reference value
|
||||
assertEquals(CellType.NUMERIC, cellC.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cellC.getCellTypeEnum());
|
||||
|
||||
CellValue cv = fe.evaluate(cellA);
|
||||
double actualValue = cv.getNumberValue();
|
||||
@ -523,9 +523,9 @@ public final class TestCountFuncs extends TestCase {
|
||||
for (int rowIx=9; rowIx<=14; rowIx++) {
|
||||
HSSFRow row = sheet2.getRow(rowIx-1);
|
||||
HSSFCell cellA = row.getCell(0); // cell containing a formula with COUNTIF
|
||||
assertEquals(CellType.FORMULA, cellA.getCellType());
|
||||
assertEquals(CellType.FORMULA, cellA.getCellTypeEnum());
|
||||
HSSFCell cellC = row.getCell(2); // cell with a reference value
|
||||
assertEquals(CellType.NUMERIC, cellC.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cellC.getCellTypeEnum());
|
||||
|
||||
CellValue cv = fe.evaluate(cellA);
|
||||
double actualValue = cv.getNumberValue();
|
||||
|
@ -58,12 +58,12 @@ public final class TestNper {
|
||||
cell.setCellFormula("NPER(12,4500,100000,100000)");
|
||||
cell.setCellValue(15.0);
|
||||
assertEquals("NPER(12,4500,100000,100000)", cell.getCellFormula());
|
||||
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(15.0, cell.getNumericCellValue(), 0.0);
|
||||
|
||||
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
||||
fe.evaluateFormulaCell(cell);
|
||||
assertEquals(CellType.ERROR, cell.getCachedFormulaResultType());
|
||||
assertEquals(CellType.ERROR, cell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(FormulaError.NUM.getCode(), cell.getErrorCellValue());
|
||||
wb.close();
|
||||
}
|
||||
|
@ -952,7 +952,7 @@ public abstract class BaseTestBugzillaIssues {
|
||||
assertEquals(1, cArray.length);*/
|
||||
|
||||
Cell cell = row.getCell(0);
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
}
|
||||
|
||||
{ // overwrite the row
|
||||
@ -1136,12 +1136,12 @@ public abstract class BaseTestBugzillaIssues {
|
||||
fe.evaluateFormulaCell(cfs);
|
||||
|
||||
// Now test
|
||||
assertEquals(CellType.NUMERIC, cn.getCellType());
|
||||
assertEquals(CellType.STRING, cs.getCellType());
|
||||
assertEquals(CellType.FORMULA, cfn.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cfn.getCachedFormulaResultType());
|
||||
assertEquals(CellType.FORMULA, cfs.getCellType());
|
||||
assertEquals(CellType.STRING, cfs.getCachedFormulaResultType());
|
||||
assertEquals(CellType.NUMERIC, cn.getCellTypeEnum());
|
||||
assertEquals(CellType.STRING, cs.getCellTypeEnum());
|
||||
assertEquals(CellType.FORMULA, cfn.getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, cfn.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(CellType.FORMULA, cfs.getCellTypeEnum());
|
||||
assertEquals(CellType.STRING, cfs.getCachedFormulaResultTypeEnum());
|
||||
|
||||
// Different ways of retrieving
|
||||
assertEquals(1.2, cn.getNumericCellValue(), 0);
|
||||
@ -1383,7 +1383,7 @@ public abstract class BaseTestBugzillaIssues {
|
||||
Sheet s = wb.createSheet();
|
||||
Cell cell = s.createRow(0).createCell(0);
|
||||
cell.setCellValue((String)null);
|
||||
assertEquals(CellType.BLANK, cell.getCellType());
|
||||
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
|
||||
|
||||
_testDataProvider.trackAllColumnsForAutosizing(s);
|
||||
|
||||
@ -1554,8 +1554,8 @@ public abstract class BaseTestBugzillaIssues {
|
||||
Cell cell = row.getCell(cellId);
|
||||
|
||||
System.out.println("Formula:" + cell.getCellFormula());
|
||||
if (CellType.FORMULA == cell.getCellType()) {
|
||||
CellType formulaResultType = cell.getCachedFormulaResultType();
|
||||
if (CellType.FORMULA == cell.getCellTypeEnum()) {
|
||||
CellType formulaResultType = cell.getCachedFormulaResultTypeEnum();
|
||||
System.out.println("Formula Result Type:" + formulaResultType);
|
||||
}
|
||||
|
||||
@ -1569,8 +1569,8 @@ public abstract class BaseTestBugzillaIssues {
|
||||
cell = row.getCell(cellId);
|
||||
System.out.println("Formula:" + cell.getCellFormula());
|
||||
|
||||
if (CellType.FORMULA == cell.getCellType()) {
|
||||
CellType formulaResultType = cell.getCachedFormulaResultType();
|
||||
if (CellType.FORMULA == cell.getCellTypeEnum()) {
|
||||
CellType formulaResultType = cell.getCachedFormulaResultTypeEnum();
|
||||
System.out.println("Formula Result Type:" + formulaResultType);
|
||||
}
|
||||
|
||||
|
@ -60,13 +60,13 @@ public abstract class BaseTestCell {
|
||||
|
||||
cell.setCellValue(1.2);
|
||||
assertEquals(1.2, cell.getNumericCellValue(), 0.0001);
|
||||
assertEquals(CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertProhibitedValueAccess(cell, CellType.BOOLEAN, CellType.STRING,
|
||||
CellType.FORMULA, CellType.ERROR);
|
||||
|
||||
cell.setCellValue(false);
|
||||
assertEquals(false, cell.getBooleanCellValue());
|
||||
assertEquals(CellType.BOOLEAN, cell.getCellType());
|
||||
assertEquals(CellType.BOOLEAN, cell.getCellTypeEnum());
|
||||
cell.setCellValue(true);
|
||||
assertEquals(true, cell.getBooleanCellValue());
|
||||
assertProhibitedValueAccess(cell, CellType.NUMERIC, CellType.STRING,
|
||||
@ -75,14 +75,14 @@ public abstract class BaseTestCell {
|
||||
cell.setCellValue(factory.createRichTextString("Foo"));
|
||||
assertEquals("Foo", cell.getRichStringCellValue().getString());
|
||||
assertEquals("Foo", cell.getStringCellValue());
|
||||
assertEquals(CellType.STRING, cell.getCellType());
|
||||
assertEquals(CellType.STRING, cell.getCellTypeEnum());
|
||||
assertProhibitedValueAccess(cell, CellType.NUMERIC, CellType.BOOLEAN,
|
||||
CellType.FORMULA, CellType.ERROR);
|
||||
|
||||
cell.setCellValue("345");
|
||||
assertEquals("345", cell.getRichStringCellValue().getString());
|
||||
assertEquals("345", cell.getStringCellValue());
|
||||
assertEquals(CellType.STRING, cell.getCellType());
|
||||
assertEquals(CellType.STRING, cell.getCellTypeEnum());
|
||||
assertProhibitedValueAccess(cell, CellType.NUMERIC, CellType.BOOLEAN,
|
||||
CellType.FORMULA, CellType.ERROR);
|
||||
|
||||
@ -90,19 +90,19 @@ public abstract class BaseTestCell {
|
||||
c.setTimeInMillis(123456789);
|
||||
cell.setCellValue(c.getTime());
|
||||
assertEquals(c.getTime().getTime(), cell.getDateCellValue().getTime());
|
||||
assertEquals(CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertProhibitedValueAccess(cell, CellType.BOOLEAN, CellType.STRING,
|
||||
CellType.FORMULA, CellType.ERROR);
|
||||
|
||||
cell.setCellValue(c);
|
||||
assertEquals(c.getTime().getTime(), cell.getDateCellValue().getTime());
|
||||
assertEquals(CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertProhibitedValueAccess(cell, CellType.BOOLEAN, CellType.STRING,
|
||||
CellType.FORMULA, CellType.ERROR);
|
||||
|
||||
cell.setCellErrorValue(FormulaError.NA.getCode());
|
||||
assertEquals(FormulaError.NA.getCode(), cell.getErrorCellValue());
|
||||
assertEquals(CellType.ERROR, cell.getCellType());
|
||||
assertEquals(CellType.ERROR, cell.getCellTypeEnum());
|
||||
assertProhibitedValueAccess(cell, CellType.NUMERIC, CellType.BOOLEAN,
|
||||
CellType.FORMULA, CellType.STRING);
|
||||
|
||||
@ -176,13 +176,13 @@ public abstract class BaseTestCell {
|
||||
c = r.getCell(1);
|
||||
assertEquals(0, c.getRowIndex());
|
||||
assertEquals(1, c.getColumnIndex());
|
||||
assertEquals(CellType.BOOLEAN, c.getCellType());
|
||||
assertEquals(CellType.BOOLEAN, c.getCellTypeEnum());
|
||||
assertEquals("B1 value", true, c.getBooleanCellValue());
|
||||
|
||||
c = r.getCell(2);
|
||||
assertEquals(0, c.getRowIndex());
|
||||
assertEquals(2, c.getColumnIndex());
|
||||
assertEquals(CellType.BOOLEAN, c.getCellType());
|
||||
assertEquals(CellType.BOOLEAN, c.getCellTypeEnum());
|
||||
assertEquals("C1 value", false, c.getBooleanCellValue());
|
||||
|
||||
wb2.close();
|
||||
@ -226,13 +226,13 @@ public abstract class BaseTestCell {
|
||||
c = r.getCell(1);
|
||||
assertEquals(0, c.getRowIndex());
|
||||
assertEquals(1, c.getColumnIndex());
|
||||
assertEquals(CellType.ERROR, c.getCellType());
|
||||
assertEquals(CellType.ERROR, c.getCellTypeEnum());
|
||||
assertEquals("B1 value == #NULL!", FormulaError.NULL.getCode(), c.getErrorCellValue());
|
||||
|
||||
c = r.getCell(2);
|
||||
assertEquals(0, c.getRowIndex());
|
||||
assertEquals(2, c.getColumnIndex());
|
||||
assertEquals(CellType.ERROR, c.getCellType());
|
||||
assertEquals(CellType.ERROR, c.getCellTypeEnum());
|
||||
assertEquals("C1 value == #DIV/0!", FormulaError.DIV0.getCode(), c.getErrorCellValue());
|
||||
|
||||
wb2.close();
|
||||
@ -272,7 +272,7 @@ public abstract class BaseTestCell {
|
||||
r = s.getRow(0);
|
||||
c = r.getCell(0);
|
||||
|
||||
assertEquals("Formula Cell at 0,0", CellType.FORMULA, c.getCellType());
|
||||
assertEquals("Formula Cell at 0,0", CellType.FORMULA, c.getCellTypeEnum());
|
||||
cs = c.getCellStyle();
|
||||
|
||||
assertNotNull("Formula Cell Style", cs);
|
||||
@ -347,25 +347,25 @@ public abstract class BaseTestCell {
|
||||
Cell c1 = r.createCell(0);
|
||||
c1.setCellFormula("NA()");
|
||||
assertEquals(0.0, c1.getNumericCellValue(), 0.0);
|
||||
assertEquals(CellType.NUMERIC, c1.getCachedFormulaResultType());
|
||||
assertEquals(CellType.NUMERIC, c1.getCachedFormulaResultTypeEnum());
|
||||
c1.setCellValue(10);
|
||||
assertEquals(10.0, c1.getNumericCellValue(), 0.0);
|
||||
assertEquals(CellType.FORMULA, c1.getCellType());
|
||||
assertEquals(CellType.NUMERIC, c1.getCachedFormulaResultType());
|
||||
assertEquals(CellType.FORMULA, c1.getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, c1.getCachedFormulaResultTypeEnum());
|
||||
|
||||
Cell c2 = r.createCell(1);
|
||||
c2.setCellFormula("NA()");
|
||||
assertEquals(0.0, c2.getNumericCellValue(), 0.0);
|
||||
assertEquals(CellType.NUMERIC, c2.getCachedFormulaResultType());
|
||||
assertEquals(CellType.NUMERIC, c2.getCachedFormulaResultTypeEnum());
|
||||
c2.setCellValue("I changed!");
|
||||
assertEquals("I changed!", c2.getStringCellValue());
|
||||
assertEquals(CellType.FORMULA, c2.getCellType());
|
||||
assertEquals(CellType.STRING, c2.getCachedFormulaResultType());
|
||||
assertEquals(CellType.FORMULA, c2.getCellTypeEnum());
|
||||
assertEquals(CellType.STRING, c2.getCachedFormulaResultTypeEnum());
|
||||
|
||||
//calglin Cell.setCellFormula(null) for a non-formula cell
|
||||
Cell c3 = r.createCell(2);
|
||||
c3.setCellFormula(null);
|
||||
assertEquals(CellType.BLANK, c3.getCellType());
|
||||
assertEquals(CellType.BLANK, c3.getCellTypeEnum());
|
||||
wb.close();
|
||||
|
||||
}
|
||||
@ -420,11 +420,11 @@ public abstract class BaseTestCell {
|
||||
Cell cell = createACell(wb);
|
||||
|
||||
cell.setCellValue("TRUE");
|
||||
assertEquals(CellType.STRING, cell.getCellType());
|
||||
assertEquals(CellType.STRING, cell.getCellTypeEnum());
|
||||
// test conversion of cell from text to boolean
|
||||
cell.setCellType(CellType.BOOLEAN);
|
||||
|
||||
assertEquals(CellType.BOOLEAN, cell.getCellType());
|
||||
assertEquals(CellType.BOOLEAN, cell.getCellTypeEnum());
|
||||
assertEquals(true, cell.getBooleanCellValue());
|
||||
cell.setCellType(CellType.STRING);
|
||||
assertEquals("TRUE", cell.getRichStringCellValue().getString());
|
||||
@ -432,7 +432,7 @@ public abstract class BaseTestCell {
|
||||
// 'false' text to bool and back
|
||||
cell.setCellValue("FALSE");
|
||||
cell.setCellType(CellType.BOOLEAN);
|
||||
assertEquals(CellType.BOOLEAN, cell.getCellType());
|
||||
assertEquals(CellType.BOOLEAN, cell.getCellTypeEnum());
|
||||
assertEquals(false, cell.getBooleanCellValue());
|
||||
cell.setCellType(CellType.STRING);
|
||||
assertEquals("FALSE", cell.getRichStringCellValue().getString());
|
||||
@ -589,17 +589,17 @@ public abstract class BaseTestCell {
|
||||
|
||||
cell = row.createCell(0, CellType.NUMERIC);
|
||||
cell.setCellValue(1.0);
|
||||
assertEquals(CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertEquals(1.0, cell.getNumericCellValue(), 0.0);
|
||||
|
||||
cell = row.createCell(1, CellType.NUMERIC);
|
||||
cell.setCellValue(2.0);
|
||||
assertEquals(CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertEquals(2.0, cell.getNumericCellValue(), 0.0);
|
||||
|
||||
cell = row.createCell(2, CellType.FORMULA);
|
||||
cell.setCellFormula("SUM(A1:B1)");
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("SUM(A1:B1)", cell.getCellFormula());
|
||||
|
||||
//serialize and check again
|
||||
@ -607,15 +607,15 @@ public abstract class BaseTestCell {
|
||||
wb1.close();
|
||||
row = wb2.getSheetAt(0).getRow(0);
|
||||
cell = row.getCell(0);
|
||||
assertEquals(CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertEquals(1.0, cell.getNumericCellValue(), 0.0);
|
||||
|
||||
cell = row.getCell(1);
|
||||
assertEquals(CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
assertEquals(2.0, cell.getNumericCellValue(), 0.0);
|
||||
|
||||
cell = row.getCell(2);
|
||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("SUM(A1:B1)", cell.getCellFormula());
|
||||
wb2.close();
|
||||
}
|
||||
@ -672,17 +672,17 @@ public abstract class BaseTestCell {
|
||||
|
||||
Cell cell0 = row.createCell(0);
|
||||
cell0.setCellValue(Double.NaN);
|
||||
assertEquals("Double.NaN should change cell type to CellType#ERROR", CellType.ERROR, cell0.getCellType());
|
||||
assertEquals("Double.NaN should change cell type to CellType#ERROR", CellType.ERROR, cell0.getCellTypeEnum());
|
||||
assertEquals("Double.NaN should change cell value to #NUM!", FormulaError.NUM, forInt(cell0.getErrorCellValue()));
|
||||
|
||||
Cell cell1 = row.createCell(1);
|
||||
cell1.setCellValue(Double.POSITIVE_INFINITY);
|
||||
assertEquals("Double.POSITIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell1.getCellType());
|
||||
assertEquals("Double.POSITIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell1.getCellTypeEnum());
|
||||
assertEquals("Double.POSITIVE_INFINITY should change cell value to #DIV/0!", FormulaError.DIV0, forInt(cell1.getErrorCellValue()));
|
||||
|
||||
Cell cell2 = row.createCell(2);
|
||||
cell2.setCellValue(Double.NEGATIVE_INFINITY);
|
||||
assertEquals("Double.NEGATIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell2.getCellType());
|
||||
assertEquals("Double.NEGATIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell2.getCellTypeEnum());
|
||||
assertEquals("Double.NEGATIVE_INFINITY should change cell value to #DIV/0!", FormulaError.DIV0, forInt(cell2.getErrorCellValue()));
|
||||
|
||||
Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
|
||||
@ -690,15 +690,15 @@ public abstract class BaseTestCell {
|
||||
row = wb2.getSheetAt(0).getRow(0);
|
||||
|
||||
cell0 = row.getCell(0);
|
||||
assertEquals(CellType.ERROR, cell0.getCellType());
|
||||
assertEquals(CellType.ERROR, cell0.getCellTypeEnum());
|
||||
assertEquals(FormulaError.NUM, forInt(cell0.getErrorCellValue()));
|
||||
|
||||
cell1 = row.getCell(1);
|
||||
assertEquals(CellType.ERROR, cell1.getCellType());
|
||||
assertEquals(CellType.ERROR, cell1.getCellTypeEnum());
|
||||
assertEquals(FormulaError.DIV0, forInt(cell1.getErrorCellValue()));
|
||||
|
||||
cell2 = row.getCell(2);
|
||||
assertEquals(CellType.ERROR, cell2.getCellType());
|
||||
assertEquals(CellType.ERROR, cell2.getCellTypeEnum());
|
||||
assertEquals(FormulaError.DIV0, forInt(cell2.getErrorCellValue()));
|
||||
wb2.close();
|
||||
}
|
||||
@ -899,21 +899,21 @@ public abstract class BaseTestCell {
|
||||
RichTextString nullStr = null;
|
||||
cell.setCellValue(nullStr);
|
||||
assertEquals("", cell.getStringCellValue());
|
||||
assertEquals(CellType.BLANK, cell.getCellType());
|
||||
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
|
||||
|
||||
cell = sheet.createRow(0).createCell(1);
|
||||
cell.setCellValue(1.2d);
|
||||
assertEquals(CellType.NUMERIC, cell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
|
||||
cell.setCellValue(nullStr);
|
||||
assertEquals("", cell.getStringCellValue());
|
||||
assertEquals(CellType.BLANK, cell.getCellType());
|
||||
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
|
||||
|
||||
cell = sheet.createRow(0).createCell(1);
|
||||
cell.setCellValue(wb.getCreationHelper().createRichTextString("Test"));
|
||||
assertEquals(CellType.STRING, cell.getCellType());
|
||||
assertEquals(CellType.STRING, cell.getCellTypeEnum());
|
||||
cell.setCellValue(nullStr);
|
||||
assertEquals("", cell.getStringCellValue());
|
||||
assertEquals(CellType.BLANK, cell.getCellType());
|
||||
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
|
||||
|
||||
wb.close();
|
||||
}
|
||||
|
@ -256,36 +256,36 @@ public abstract class BaseTestRow {
|
||||
row.createCell(5).setCellValue(4);
|
||||
|
||||
// First up, no policy given, uses default
|
||||
assertEquals(CellType.STRING, row.getCell(0).getCellType());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1).getCellType());
|
||||
assertEquals(CellType.STRING, row.getCell(0).getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1).getCellTypeEnum());
|
||||
assertEquals(null, row.getCell(2));
|
||||
assertEquals(null, row.getCell(3));
|
||||
assertEquals(CellType.BLANK, row.getCell(4).getCellType());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(5).getCellType());
|
||||
assertEquals(CellType.BLANK, row.getCell(4).getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(5).getCellTypeEnum());
|
||||
|
||||
// RETURN_NULL_AND_BLANK - same as default
|
||||
assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
|
||||
assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellTypeEnum());
|
||||
assertEquals(null, row.getCell(2, MissingCellPolicy.RETURN_NULL_AND_BLANK));
|
||||
assertEquals(null, row.getCell(3, MissingCellPolicy.RETURN_NULL_AND_BLANK));
|
||||
assertEquals(CellType.BLANK, row.getCell(4, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
|
||||
assertEquals(CellType.BLANK, row.getCell(4, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellTypeEnum());
|
||||
|
||||
// RETURN_BLANK_AS_NULL - nearly the same
|
||||
assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType());
|
||||
assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellTypeEnum());
|
||||
assertEquals(null, row.getCell(2, MissingCellPolicy.RETURN_BLANK_AS_NULL));
|
||||
assertEquals(null, row.getCell(3, MissingCellPolicy.RETURN_BLANK_AS_NULL));
|
||||
assertEquals(null, row.getCell(4, MissingCellPolicy.RETURN_BLANK_AS_NULL));
|
||||
assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellTypeEnum());
|
||||
|
||||
// CREATE_NULL_AS_BLANK - creates as needed
|
||||
assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
|
||||
assertEquals(CellType.BLANK, row.getCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
|
||||
assertEquals(CellType.BLANK, row.getCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
|
||||
assertEquals(CellType.BLANK, row.getCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
|
||||
assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum());
|
||||
assertEquals(CellType.BLANK, row.getCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum());
|
||||
assertEquals(CellType.BLANK, row.getCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum());
|
||||
assertEquals(CellType.BLANK, row.getCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum());
|
||||
|
||||
// Check created ones get the right column
|
||||
assertEquals(0, row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getColumnIndex());
|
||||
@ -300,12 +300,12 @@ public abstract class BaseTestRow {
|
||||
// that that is now used if no policy given
|
||||
workbook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL);
|
||||
|
||||
assertEquals(CellType.STRING, row.getCell(0).getCellType());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1).getCellType());
|
||||
assertEquals(CellType.STRING, row.getCell(0).getCellTypeEnum());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(1).getCellTypeEnum());
|
||||
assertEquals(null, row.getCell(2));
|
||||
assertEquals(null, row.getCell(3));
|
||||
assertEquals(null, row.getCell(4));
|
||||
assertEquals(CellType.NUMERIC, row.getCell(5).getCellType());
|
||||
assertEquals(CellType.NUMERIC, row.getCell(5).getCellTypeEnum());
|
||||
|
||||
workbook.close();
|
||||
}
|
||||
@ -420,7 +420,7 @@ public abstract class BaseTestRow {
|
||||
assertTrue(cell5 == it.next());
|
||||
assertTrue(it.hasNext());
|
||||
assertTrue(cell2 == it.next());
|
||||
assertEquals(CellType.STRING, cell5.getCellType());
|
||||
assertEquals(CellType.STRING, cell5.getCellTypeEnum());
|
||||
wb.close();
|
||||
}
|
||||
|
||||
|
@ -344,7 +344,7 @@ public abstract class BaseTestSheetAutosizeColumn {
|
||||
Sheet sheet = workbook.getSheetAt(i);
|
||||
for (Row r : sheet) {
|
||||
for (Cell c : r) {
|
||||
if (c.getCellType() == CellType.FORMULA){
|
||||
if (c.getCellTypeEnum() == CellType.FORMULA){
|
||||
eval.evaluateFormulaCell(c);
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
|
||||
for(Cell acell : cells){
|
||||
assertTrue(acell.isPartOfArrayFormulaGroup());
|
||||
assertEquals(CellType.FORMULA, acell.getCellType());
|
||||
assertEquals(CellType.FORMULA, acell.getCellTypeEnum());
|
||||
assertEquals("SUM(A1:A3*B1:B3)", acell.getCellFormula());
|
||||
//retrieve the range and check it is the same
|
||||
assertEquals(range.formatAsString(), acell.getArrayFormulaRange().formatAsString());
|
||||
@ -210,7 +210,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
|
||||
for(Cell acell : cr){
|
||||
assertFalse(acell.isPartOfArrayFormulaGroup());
|
||||
assertEquals(CellType.BLANK, acell.getCellType());
|
||||
assertEquals(CellType.BLANK, acell.getCellTypeEnum());
|
||||
}
|
||||
|
||||
// cells C4:C6 are not included in array formula,
|
||||
@ -279,7 +279,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
CellRange<? extends Cell> srange =
|
||||
sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5"));
|
||||
Cell scell = srange.getTopLeftCell();
|
||||
assertEquals(CellType.FORMULA, scell.getCellType());
|
||||
assertEquals(CellType.FORMULA, scell.getCellTypeEnum());
|
||||
assertEquals(0.0, scell.getNumericCellValue(), 0);
|
||||
scell.setCellValue(1.1);
|
||||
assertEquals(1.1, scell.getNumericCellValue(), 0);
|
||||
@ -288,7 +288,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
CellRange<? extends Cell> mrange =
|
||||
sheet.setArrayFormula("A1:A3*B1:B3", CellRangeAddress.valueOf("C1:C3"));
|
||||
for(Cell mcell : mrange){
|
||||
assertEquals(CellType.FORMULA, mcell.getCellType());
|
||||
assertEquals(CellType.FORMULA, mcell.getCellTypeEnum());
|
||||
assertEquals(0.0, mcell.getNumericCellValue(), 0);
|
||||
double fmlaResult = 1.2;
|
||||
mcell.setCellValue(fmlaResult);
|
||||
@ -307,10 +307,10 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
CellRange<? extends Cell> srange =
|
||||
sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5"));
|
||||
Cell scell = srange.getTopLeftCell();
|
||||
assertEquals(CellType.FORMULA, scell.getCellType());
|
||||
assertEquals(CellType.FORMULA, scell.getCellTypeEnum());
|
||||
assertEquals(0.0, scell.getNumericCellValue(), 0);
|
||||
scell.setCellType(CellType.STRING);
|
||||
assertEquals(CellType.STRING, scell.getCellType());
|
||||
assertEquals(CellType.STRING, scell.getCellTypeEnum());
|
||||
scell.setCellValue("string cell");
|
||||
assertEquals("string cell", scell.getStringCellValue());
|
||||
|
||||
@ -319,7 +319,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
sheet.setArrayFormula("A1:A3*B1:B3", CellRangeAddress.valueOf("C1:C3"));
|
||||
for(Cell mcell : mrange){
|
||||
try {
|
||||
assertEquals(CellType.FORMULA, mcell.getCellType());
|
||||
assertEquals(CellType.FORMULA, mcell.getCellTypeEnum());
|
||||
mcell.setCellType(CellType.NUMERIC);
|
||||
fail("expected exception");
|
||||
} catch (IllegalStateException e){
|
||||
@ -329,7 +329,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
}
|
||||
// a failed invocation of Cell.setCellType leaves the cell
|
||||
// in the state that it was in prior to the invocation
|
||||
assertEquals(CellType.FORMULA, mcell.getCellType());
|
||||
assertEquals(CellType.FORMULA, mcell.getCellTypeEnum());
|
||||
assertTrue(mcell.isPartOfArrayFormulaGroup());
|
||||
}
|
||||
workbook.close();
|
||||
@ -344,13 +344,13 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5"));
|
||||
Cell scell = srange.getTopLeftCell();
|
||||
assertEquals("SUM(A4:A6,B4:B6)", scell.getCellFormula());
|
||||
assertEquals(CellType.FORMULA, scell.getCellType());
|
||||
assertEquals(CellType.FORMULA, scell.getCellTypeEnum());
|
||||
assertTrue(scell.isPartOfArrayFormulaGroup());
|
||||
scell.setCellFormula("SUM(A4,A6)");
|
||||
//we are now a normal formula cell
|
||||
assertEquals("SUM(A4,A6)", scell.getCellFormula());
|
||||
assertFalse(scell.isPartOfArrayFormulaGroup());
|
||||
assertEquals(CellType.FORMULA, scell.getCellType());
|
||||
assertEquals(CellType.FORMULA, scell.getCellTypeEnum());
|
||||
//check that setting formula result works
|
||||
assertEquals(0.0, scell.getNumericCellValue(), 0);
|
||||
scell.setCellValue(33.0);
|
||||
@ -396,7 +396,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
|
||||
//re-create the removed cell
|
||||
scell = srow.createCell(cra.getFirstColumn());
|
||||
assertEquals(CellType.BLANK, scell.getCellType());
|
||||
assertEquals(CellType.BLANK, scell.getCellTypeEnum());
|
||||
assertFalse(scell.isPartOfArrayFormulaGroup());
|
||||
|
||||
//we cannot remove cells included in a multi-cell array formula
|
||||
@ -417,7 +417,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
// in the state that it was in prior to the invocation
|
||||
assertSame(mcell, mrow.getCell(columnIndex));
|
||||
assertTrue(mcell.isPartOfArrayFormulaGroup());
|
||||
assertEquals(CellType.FORMULA, mcell.getCellType());
|
||||
assertEquals(CellType.FORMULA, mcell.getCellTypeEnum());
|
||||
}
|
||||
|
||||
workbook.close();
|
||||
@ -433,7 +433,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
CellRange<? extends Cell> srange =
|
||||
sheet.setArrayFormula("SUM(A4:A6,B4:B6)", cra);
|
||||
Cell scell = srange.getTopLeftCell();
|
||||
assertEquals(CellType.FORMULA, scell.getCellType());
|
||||
assertEquals(CellType.FORMULA, scell.getCellTypeEnum());
|
||||
|
||||
Row srow = scell.getRow();
|
||||
assertSame(srow, sheet.getRow(cra.getFirstRow()));
|
||||
@ -442,7 +442,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
|
||||
//re-create the removed row and cell
|
||||
scell = sheet.createRow(cra.getFirstRow()).createCell(cra.getFirstColumn());
|
||||
assertEquals(CellType.BLANK, scell.getCellType());
|
||||
assertEquals(CellType.BLANK, scell.getCellTypeEnum());
|
||||
assertFalse(scell.isPartOfArrayFormulaGroup());
|
||||
|
||||
//we cannot remove rows with cells included in a multi-cell array formula
|
||||
@ -463,7 +463,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
assertSame(mrow, sheet.getRow(mrow.getRowNum()));
|
||||
assertSame(mcell, mrow.getCell(columnIndex));
|
||||
assertTrue(mcell.isPartOfArrayFormulaGroup());
|
||||
assertEquals(CellType.FORMULA, mcell.getCellType());
|
||||
assertEquals(CellType.FORMULA, mcell.getCellTypeEnum());
|
||||
}
|
||||
|
||||
workbook.close();
|
||||
@ -481,7 +481,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
|
||||
Cell scell = srange.getTopLeftCell();
|
||||
sheet.addMergedRegion(CellRangeAddress.valueOf("B5:C6"));
|
||||
//we are still an array formula
|
||||
assertEquals(CellType.FORMULA, scell.getCellType());
|
||||
assertEquals(CellType.FORMULA, scell.getCellTypeEnum());
|
||||
assertTrue(scell.isPartOfArrayFormulaGroup());
|
||||
assertEquals(1, sheet.getNumMergedRegions());
|
||||
|
||||
|
@ -50,7 +50,7 @@ public final class TestSheetBuilder extends TestCase {
|
||||
Row firstRow = sheet.getRow(0);
|
||||
Cell firstCell = firstRow.getCell(0);
|
||||
|
||||
assertEquals(firstCell.getCellType(), CellType.NUMERIC);
|
||||
assertEquals(firstCell.getCellTypeEnum(), CellType.NUMERIC);
|
||||
assertEquals(1.0, firstCell.getNumericCellValue(), 0.00001);
|
||||
|
||||
|
||||
@ -59,11 +59,11 @@ public final class TestSheetBuilder extends TestCase {
|
||||
assertNull(secondRow.getCell(2));
|
||||
|
||||
Row thirdRow = sheet.getRow(2);
|
||||
assertEquals(CellType.STRING, thirdRow.getCell(0).getCellType());
|
||||
assertEquals(CellType.STRING, thirdRow.getCell(0).getCellTypeEnum());
|
||||
String cellValue = thirdRow.getCell(0).getStringCellValue();
|
||||
assertEquals(testData[2][0].toString(), cellValue);
|
||||
|
||||
assertEquals(CellType.FORMULA, thirdRow.getCell(2).getCellType());
|
||||
assertEquals(CellType.FORMULA, thirdRow.getCell(2).getCellTypeEnum());
|
||||
assertEquals("A1+B2", thirdRow.getCell(2).getCellFormula());
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public final class TestSheetBuilder extends TestCase {
|
||||
|
||||
Cell emptyCell = sheet.getRow(1).getCell(1);
|
||||
assertNotNull(emptyCell);
|
||||
assertEquals(CellType.BLANK, emptyCell.getCellType());
|
||||
assertEquals(CellType.BLANK, emptyCell.getCellTypeEnum());
|
||||
}
|
||||
|
||||
public void testSheetName() {
|
||||
|
Loading…
Reference in New Issue
Block a user