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