aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2016-07-04 10:15:18 +0000
committerJaven O'Neal <onealj@apache.org>2016-07-04 10:15:18 +0000
commit8d31c01f4035aaa40467d96fe1de1f88ed801cf8 (patch)
tree41f1ce223e92a49154a096a3e5f0c5d55a174975 /src/ooxml
parentfb8c79d96c2f0ddffb13f5b96c0f65b66c77ce5f (diff)
downloadpoi-8d31c01f4035aaa40467d96fe1de1f88ed801cf8.tar.gz
poi-8d31c01f4035aaa40467d96fe1de1f88ed801cf8.zip
bug 59791: replace deprecated Cell.CELL_TYPE_* usage with CellType.*
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751240 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java3
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java2
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java3
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java24
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java4
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java3
-rw-r--r--src/ooxml/testcases/org/apache/poi/ss/formula/TestStructuredReferences.java3
-rw-r--r--src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestProper.java5
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java15
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java13
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java3
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java27
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java7
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java53
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java6
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java7
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java3
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java77
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java3
19 files changed, 130 insertions, 131 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java
index 3415af3010..965534f34b 100644
--- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java
+++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java
@@ -22,6 +22,7 @@ import org.apache.poi.ss.formula.IStabilityClassifier;
import org.apache.poi.ss.formula.WorkbookEvaluator;
import org.apache.poi.ss.formula.udf.UDFFinder;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.util.POILogFactory;
@@ -120,7 +121,7 @@ public final class SXSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator {
// Evaluate what we have
for (Row r : sheet) {
for (Cell c : r) {
- if (c.getCellType() == Cell.CELL_TYPE_FORMULA) {
+ if (c.getCellType() == CellType.FORMULA) {
eval.evaluateFormulaCell(c);
}
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java
index 81359d3857..6d337f4465 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java
@@ -110,7 +110,7 @@ public abstract class BaseXSSFFormulaEvaluator implements FormulaEvaluator, Work
* and the result. If you want the cell replaced with
* the result of the formula, use {@link #evaluate(org.apache.poi.ss.usermodel.Cell)} }
* @param cell The cell to evaluate
- * @return The type of the formula result (the cell's type remains as HSSFCell.CELL_TYPE_FORMULA however)
+ * @return The type of the formula result (the cell's type remains as CellType.FORMULA however)
*/
public CellType evaluateFormulaCell(Cell cell) {
if (cell == null || cell.getCellType() != CellType.FORMULA) {
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java
index c611e13e38..8ab465aff1 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java
@@ -29,6 +29,7 @@ import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.AreaReference;
@@ -143,7 +144,7 @@ public class XSSFPivotCacheDefinition extends POIXMLDocumentPart{
//General number format
cf.setNumFmtId(0);
Cell cell = row.getCell(i);
- cell.setCellType(Cell.CELL_TYPE_STRING);
+ cell.setCellType(CellType.STRING);
cf.setName(row.getCell(i).getStringCellValue());
cf.addNewSharedItems();
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java
index d0e9d1a8ce..9f68649199 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java
@@ -31,6 +31,7 @@ import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataConsolidateFunction;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.AreaReference;
@@ -39,26 +40,7 @@ import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCacheSource;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColFields;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDataField;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDataFields;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTField;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTItems;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTLocation;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageField;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageFields;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotCacheDefinition;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotField;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotFields;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotTableDefinition;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotTableStyle;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRowFields;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheetSource;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STAxis;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STDataConsolidateFunction;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STItemType;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STSourceType;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
public class XSSFPivotTable extends POIXMLDocumentPart {
@@ -357,7 +339,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart {
dataField.setSubtotal(STDataConsolidateFunction.Enum.forInt(function.getValue()));
Cell cell = getDataSheet().getRow(pivotArea.getFirstCell().getRow())
.getCell(pivotArea.getFirstCell().getCol() + columnIndex);
- cell.setCellType(Cell.CELL_TYPE_STRING);
+ cell.setCellType(CellType.STRING);
dataField.setName(valueFieldName);
dataField.setFld(columnIndex);
dataFields.setCount(dataFields.sizeOfDataFieldArray());
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
index 3ae3d5b579..efd45943fa 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
@@ -43,7 +43,6 @@ import javax.xml.namespace.QName;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.POIXMLException;
-
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.PartAlreadyExistsException;
import org.apache.poi.openxml4j.opc.PackagePart;
@@ -58,6 +57,7 @@ import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellCopyPolicy;
import org.apache.poi.ss.usermodel.CellRange;
import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataValidation;
import org.apache.poi.ss.usermodel.DataValidationHelper;
import org.apache.poi.ss.usermodel.Footer;
@@ -3782,7 +3782,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
arrayFormulas.remove(range);
CellRange<XSSFCell> cr = getCellRange(range);
for (XSSFCell c : cr) {
- c.setCellType(Cell.CELL_TYPE_BLANK);
+ c.setCellType(CellType.BLANK);
}
return cr;
}
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java
index 99e8a1e408..107e205b98 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java
@@ -26,6 +26,7 @@ import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.formula.ptg.Pxg;
import org.apache.poi.ss.formula.ptg.Pxg3D;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFCell;
@@ -76,7 +77,7 @@ public final class XSSFFormulaUtils {
for (Sheet sh : _wb) {
for (Row row : sh) {
for (Cell cell : row) {
- if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
+ if (cell.getCellType() == CellType.FORMULA) {
updateFormula((XSSFCell) cell, oldName, newName);
}
}
diff --git a/src/ooxml/testcases/org/apache/poi/ss/formula/TestStructuredReferences.java b/src/ooxml/testcases/org/apache/poi/ss/formula/TestStructuredReferences.java
index a21ad32a05..fd598a479b 100644
--- a/src/ooxml/testcases/org/apache/poi/ss/formula/TestStructuredReferences.java
+++ b/src/ooxml/testcases/org/apache/poi/ss/formula/TestStructuredReferences.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Table;
@@ -72,7 +73,7 @@ public class TestStructuredReferences {
private static void confirm(FormulaEvaluator fe, Cell cell, double expectedResult) {
fe.clearAllCachedResultValues();
CellValue cv = fe.evaluate(cell);
- if (cv.getCellType() != Cell.CELL_TYPE_NUMERIC) {
+ if (cv.getCellType() != CellType.NUMERIC) {
fail("expected numeric cell type but got " + cv.formatAsString());
}
assertEquals(expectedResult, cv.getNumberValue(), 0.0);
diff --git a/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestProper.java b/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestProper.java
index cac071f416..40500480a6 100644
--- a/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestProper.java
+++ b/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestProper.java
@@ -23,6 +23,7 @@ import junit.framework.TestCase;
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Sheet;
@@ -52,7 +53,7 @@ public final class TestProper extends TestCase {
private void confirm(Workbook wb) {
Sheet sheet = wb.createSheet("new sheet");
cell11 = sheet.createRow(0).createCell(0);
- cell11.setCellType(XSSFCell.CELL_TYPE_FORMULA);
+ cell11.setCellType(CellType.FORMULA);
confirm("PROPER(\"hi there\")", "Hi There");
confirm("PROPER(\"what's up\")", "What'S Up");
@@ -77,7 +78,7 @@ public final class TestProper extends TestCase {
cell11.setCellFormula(formulaText);
evaluator.clearAllCachedResultValues();
CellValue cv = evaluator.evaluate(cell11);
- if (cv.getCellType() != Cell.CELL_TYPE_STRING) {
+ if (cv.getCellType() != CellType.STRING) {
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
}
String actualValue = cv.getStringValue();
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java b/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java
index ccc883dd30..b36b867736 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java
@@ -32,6 +32,7 @@ import junit.framework.TestCase;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.util.XMLHelper;
@@ -513,30 +514,30 @@ public final class TestXSSFExportToXML extends TestCase {
Cell cString = row.createCell(0);
cString.setCellValue("somestring");
- cString.setCellType(XSSFCell.CELL_TYPE_STRING);
+ cString.setCellType(CellType.STRING);
Cell cBoolean = row.createCell(1);
cBoolean.setCellValue(true);
- cBoolean.setCellType(XSSFCell.CELL_TYPE_BOOLEAN);
+ cBoolean.setCellType(CellType.BOOLEAN);
Cell cError = row.createCell(2);
- cError.setCellType(XSSFCell.CELL_TYPE_ERROR);
+ cError.setCellType(CellType.ERROR);
Cell cFormulaString = row.createCell(3);
cFormulaString.setCellFormula("A1");
- cFormulaString.setCellType(XSSFCell.CELL_TYPE_FORMULA);
+ cFormulaString.setCellType(CellType.FORMULA);
Cell cFormulaNumeric = row.createCell(4);
cFormulaNumeric.setCellFormula("F1");
- cFormulaNumeric.setCellType(XSSFCell.CELL_TYPE_FORMULA);
+ cFormulaNumeric.setCellType(CellType.FORMULA);
Cell cNumeric = row.createCell(5);
cNumeric.setCellValue(1.2);
- cNumeric.setCellType(XSSFCell.CELL_TYPE_NUMERIC);
+ cNumeric.setCellType(CellType.NUMERIC);
Cell cDate = row.createCell(6);
cDate.setCellValue(new Date());
- cDate.setCellType(XSSFCell.CELL_TYPE_NUMERIC);
+ cDate.setCellType(CellType.NUMERIC);
boolean found = false;
for (POIXMLDocumentPart p : wb.getRelations()) {
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java b/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java
index 0932177e00..42cf2714a5 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java
@@ -17,9 +17,12 @@
package org.apache.poi.xssf.model;
-import org.apache.poi.xssf.usermodel.*;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcCell;
import junit.framework.TestCase;
@@ -39,7 +42,7 @@ public final class TestCalculationChain extends TestCase {
XSSFSheet sheet = wb.getSheet("Test");
XSSFCell cell = sheet.getRow(0).getCell(4);
- assertEquals(XSSFCell.CELL_TYPE_FORMULA, cell.getCellType());
+ assertEquals(CellType.FORMULA, cell.getCellType());
cell.setCellFormula(null);
//the count of items is less by one
@@ -50,9 +53,9 @@ public final class TestCalculationChain extends TestCase {
assertEquals(10, c.getI());
assertEquals("C1", c.getR());
- assertEquals(XSSFCell.CELL_TYPE_STRING, cell.getCellType());
+ assertEquals(CellType.STRING, cell.getCellType());
cell.setCellValue("ABC");
- assertEquals(XSSFCell.CELL_TYPE_STRING, cell.getCellType());
+ assertEquals(CellType.STRING, cell.getCellType());
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java
index 4fbdbcd6e9..67ebe1ef00 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java
@@ -37,6 +37,7 @@ import org.apache.poi.POITestCase;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.BaseTestXWorkbook;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
@@ -524,7 +525,7 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook {
Arrays.fill(useless, 0, 10, ' ');
System.arraycopy(prefix, 0, useless, 0, prefix.length);
String ul = new String(useless);
- r.createCell(col, Cell.CELL_TYPE_STRING).setCellValue(ul);
+ r.createCell(col, CellType.STRING).setCellValue(ul);
ul = null;
}
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
index b9c5c9809a..8c6951de18 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
@@ -34,6 +34,7 @@ import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellCopyPolicy;
import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.Font;
@@ -70,7 +71,7 @@ public final class TestXSSFCell extends BaseTestXCell {
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(0);
Cell cell = row.getCell(0);
- cell.setCellType(Cell.CELL_TYPE_STRING);
+ cell.setCellType(CellType.STRING);
cell.setCellValue("456");
wb.close();
}
@@ -133,13 +134,13 @@ public final class TestXSSFCell extends BaseTestXCell {
assertNull(str.getString());
cell_0.setCellValue(str);
assertEquals(0, sst.getCount());
- assertEquals(Cell.CELL_TYPE_BLANK, cell_0.getCellType());
+ assertEquals(CellType.BLANK, cell_0.getCellType());
//case 2. cell.setCellValue((String)null);
Cell cell_1 = row.createCell(1);
cell_1.setCellValue((String)null);
assertEquals(0, sst.getCount());
- assertEquals(Cell.CELL_TYPE_BLANK, cell_1.getCellType());
+ assertEquals(CellType.BLANK, cell_1.getCellType());
wb.close();
}
@@ -151,7 +152,7 @@ public final class TestXSSFCell extends BaseTestXCell {
CTCell ctCell = cell.getCTCell(); //low-level bean holding cell's xml
cell.setCellFormula("A2");
- assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals("A2", cell.getCellFormula());
//the value is not set and cell's type='N' which means blank
assertEquals(STCellType.N, ctCell.getT());
@@ -159,7 +160,7 @@ public final class TestXSSFCell extends BaseTestXCell {
//set cached formula value
cell.setCellValue("t='str'");
//we are still of 'formula' type
- assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals("A2", cell.getCellFormula());
//cached formula value is set and cell's type='STR'
assertEquals(STCellType.STR, ctCell.getT());
@@ -167,14 +168,14 @@ public final class TestXSSFCell extends BaseTestXCell {
//now remove the formula, the cached formula result remains
cell.setCellFormula(null);
- assertEquals(Cell.CELL_TYPE_STRING, cell.getCellType());
+ assertEquals(CellType.STRING, cell.getCellType());
assertEquals(STCellType.STR, ctCell.getT());
//the line below failed prior to fix of Bug #47889
assertEquals("t='str'", cell.getStringCellValue());
//revert to a blank cell
cell.setCellValue((String)null);
- assertEquals(Cell.CELL_TYPE_BLANK, cell.getCellType());
+ assertEquals(CellType.BLANK, cell.getCellType());
assertEquals(STCellType.N, ctCell.getT());
assertEquals("", cell.getStringCellValue());
} finally {
@@ -194,7 +195,7 @@ public final class TestXSSFCell extends BaseTestXCell {
//try a string cell
cell = sh.getRow(0).getCell(0);
- assertEquals(Cell.CELL_TYPE_STRING, cell.getCellType());
+ assertEquals(CellType.STRING, cell.getCellType());
assertEquals("a", cell.getStringCellValue());
assertEquals("a", cell.toString());
//Gnumeric produces spreadsheets without styles
@@ -203,7 +204,7 @@ public final class TestXSSFCell extends BaseTestXCell {
//try a numeric cell
cell = sh.getRow(1).getCell(0);
- assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+ assertEquals(CellType.NUMERIC, cell.getCellType());
assertEquals(1.0, cell.getNumericCellValue(), 0);
assertEquals("1.0", cell.toString());
//Gnumeric produces spreadsheets without styles
@@ -513,7 +514,7 @@ public final class TestXSSFCell extends BaseTestXCell {
final CellCopyPolicy policy = new CellCopyPolicy();
destCell.copyCellFrom(srcCell, policy);
- assertEquals(Cell.CELL_TYPE_FORMULA, destCell.getCellType());
+ assertEquals(CellType.FORMULA, destCell.getCellType());
assertEquals("2+3", destCell.getCellFormula());
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
}
@@ -525,7 +526,7 @@ public final class TestXSSFCell extends BaseTestXCell {
// Paste values only
final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellFormula(false).build();
destCell.copyCellFrom(srcCell, policy);
- assertEquals(Cell.CELL_TYPE_NUMERIC, destCell.getCellType());
+ assertEquals(CellType.NUMERIC, destCell.getCellType());
}
@Test
@@ -552,8 +553,8 @@ public final class TestXSSFCell extends BaseTestXCell {
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
// Old cell value should not have been overwritten
- assertNotEquals(Cell.CELL_TYPE_BLANK, destCell.getCellType());
- assertEquals(Cell.CELL_TYPE_BOOLEAN, destCell.getCellType());
+ assertNotEquals(CellType.BLANK, destCell.getCellType());
+ assertEquals(CellType.BOOLEAN, destCell.getCellType());
assertEquals(true, destCell.getBooleanCellValue());
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java
index 8be5121426..d9cbec5dd1 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java
@@ -24,6 +24,7 @@ import java.util.List;
import org.apache.poi.ss.usermodel.BaseTestDataValidation;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataValidation;
import org.apache.poi.ss.usermodel.DataValidationConstraint;
import org.apache.poi.ss.usermodel.DataValidationConstraint.OperatorType;
@@ -141,7 +142,7 @@ public class TestXSSFDataValidation extends BaseTestDataValidation {
Cell cell_13 = row1.createCell(3);
- cell_13.setCellType(Cell.CELL_TYPE_NUMERIC);
+ cell_13.setCellType(CellType.NUMERIC);
cell_13.setCellValue(validationType==ValidationType.DECIMAL ? dvalue.doubleValue() : value.intValue());
@@ -204,11 +205,11 @@ public class TestXSSFDataValidation extends BaseTestDataValidation {
String value1String = validationType==ValidationType.DECIMAL ? dvalue.toString() : value.toString();
- cell_13.setCellType(Cell.CELL_TYPE_NUMERIC);
+ cell_13.setCellType(CellType.NUMERIC);
cell_13.setCellValue(validationType==ValidationType.DECIMAL ? dvalue.doubleValue() : value.intValue());
String value2String = validationType==ValidationType.DECIMAL ? dvalue2.toString() : value2.toString();
- cell_14.setCellType(Cell.CELL_TYPE_NUMERIC);
+ cell_14.setCellType(CellType.NUMERIC);
cell_14.setCellValue(validationType==ValidationType.DECIMAL ? dvalue2.doubleValue() : value2.intValue());
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
index 87475771bd..28cc7f79a3 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
@@ -26,6 +26,7 @@ import java.util.Map;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.ss.usermodel.BaseTestFormulaEvaluator;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.ss.usermodel.FormulaError;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
@@ -369,32 +370,32 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
// sheet1 A1
XSSFCell cell = sheet1.createRow(0).createCell(0);
- cell.setCellType(Cell.CELL_TYPE_NUMERIC);
+ cell.setCellType(CellType.NUMERIC);
cell.setCellValue(1.0);
// sheet2 A1
cell = sheet2.createRow(0).createCell(0);
- cell.setCellType(Cell.CELL_TYPE_NUMERIC);
+ cell.setCellType(CellType.NUMERIC);
cell.setCellValue(1.0);
// sheet2 B1
cell = sheet2.getRow(0).createCell(1);
- cell.setCellType(Cell.CELL_TYPE_NUMERIC);
+ cell.setCellType(CellType.NUMERIC);
cell.setCellValue(1.0);
// sheet3 A1
cell = sheet3.createRow(0).createCell(0);
- cell.setCellType(Cell.CELL_TYPE_NUMERIC);
+ cell.setCellType(CellType.NUMERIC);
cell.setCellValue(1.0);
// sheet1 A2 formulae
cell = sheet1.createRow(1).createCell(0);
- cell.setCellType(Cell.CELL_TYPE_FORMULA);
+ cell.setCellType(CellType.FORMULA);
cell.setCellFormula("SUM(Sheet1:Sheet3!A1)");
// sheet1 A3 formulae
cell = sheet1.createRow(2).createCell(0);
- cell.setCellType(Cell.CELL_TYPE_FORMULA);
+ cell.setCellType(CellType.FORMULA);
cell.setCellFormula("SUM(Sheet1:Sheet3!A1:B1)");
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
@@ -416,8 +417,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
XSSFSheet sheet = wb.createSheet("test");
XSSFRow row = sheet.createRow(0);
XSSFRow row2 = sheet.createRow(1);
- XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA);
- XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC);
+ XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA);
+ XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC);
cellB1.setCellValue(10);
XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
cellA2.setCellFormula("IF(B1=0,\"\",((ROW()-ROW(A$1))*12))");
@@ -441,8 +442,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
XSSFSheet sheet = wb.createSheet("test");
XSSFRow row = sheet.createRow(0);
XSSFRow row2 = sheet.createRow(1);
- XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA);
- XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC);
+ XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA);
+ XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC);
cellB1.setCellValue(10);
XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
cellA2.setCellFormula("IF(B1=0,\"\",((ROW(A$1))))");
@@ -466,8 +467,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
XSSFSheet sheet = wb.createSheet("test");
XSSFRow row = sheet.createRow(0);
XSSFRow row2 = sheet.createRow(1);
- XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA);
- XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC);
+ XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA);
+ XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC);
cellB1.setCellValue(10);
XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
@@ -492,8 +493,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
XSSFSheet sheet = wb.createSheet("test");
XSSFRow row = sheet.createRow(0);
XSSFRow row2 = sheet.createRow(1);
- XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA);
- XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC);
+ XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA);
+ XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC);
cellB1.setCellValue(10);
XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
@@ -512,8 +513,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
XSSFSheet sheet = wb.createSheet("test");
XSSFRow row = sheet.createRow(0);
XSSFRow row2 = sheet.createRow(1);
- XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA);
- XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC);
+ XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA);
+ XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC);
cellB1.setCellValue(10);
XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
@@ -532,8 +533,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
XSSFSheet sheet = wb.createSheet("test");
XSSFRow row = sheet.createRow(0);
XSSFRow row2 = sheet.createRow(1);
- XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA);
- XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC);
+ XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA);
+ XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC);
cellB1.setCellValue(10);
XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
@@ -552,8 +553,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
XSSFSheet sheet = wb.createSheet("test");
XSSFRow row = sheet.createRow(0);
XSSFRow row2 = sheet.createRow(1);
- XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA);
- XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC);
+ XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA);
+ XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC);
cellB1.setCellValue(10);
XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
@@ -575,9 +576,9 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
- assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 0,0).getCachedFormulaResultType());
+ assertEquals(CellType.ERROR, getCell(sheet, 0,0).getCachedFormulaResultType());
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0,0).getErrorCellValue());
- assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 0,1).getCachedFormulaResultType());
+ assertEquals(CellType.ERROR, getCell(sheet, 0,1).getCachedFormulaResultType());
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0,1).getErrorCellValue());
wb.close();
@@ -596,11 +597,11 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
- assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 0, 0).getCachedFormulaResultType());
+ assertEquals(CellType.ERROR, getCell(sheet, 0, 0).getCachedFormulaResultType());
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0, 0).getErrorCellValue());
- assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 1, 0).getCachedFormulaResultType());
+ assertEquals(CellType.ERROR, getCell(sheet, 1, 0).getCachedFormulaResultType());
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 1, 0).getErrorCellValue());
- assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 0, 3).getCachedFormulaResultType());
+ assertEquals(CellType.ERROR, getCell(sheet, 0, 3).getCachedFormulaResultType());
assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0, 3).getErrorCellValue());
wb.close();
@@ -639,7 +640,7 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator {
if (cell == null) {
cell = r.createCell(column);
}
- cell.setCellType(XSSFCell.CELL_TYPE_FORMULA);
+ cell.setCellType(CellType.FORMULA);
cell.setCellFormula(formula);
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java
index 08c4ed2984..119157f682 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java
@@ -370,12 +370,12 @@ public final class TestXSSFFormulaParser {
assertEquals("MIN", toFormulaString(ptgs[1], fpb));
// Check we can round-trip - try to set a new one to a new single cell
- Cell newF = s1.getRow(0).createCell(10, Cell.CELL_TYPE_FORMULA);
+ Cell newF = s1.getRow(0).createCell(10, CellType.FORMULA);
newF.setCellFormula("SUM(Sheet2:Sheet3!A1)");
assertEquals("SUM(Sheet2:Sheet3!A1)", newF.getCellFormula());
// Check we can round-trip - try to set a new one to a cell range
- newF = s1.getRow(0).createCell(11, Cell.CELL_TYPE_FORMULA);
+ newF = s1.getRow(0).createCell(11, CellType.FORMULA);
newF.setCellFormula("MIN(Sheet1:Sheet2!A1:B2)");
assertEquals("MIN(Sheet1:Sheet2!A1:B2)", newF.getCellFormula());
@@ -465,7 +465,7 @@ public final class TestXSSFFormulaParser {
for (Row row : xsheet) {
for (Cell cell : row) {
- if (cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA) {
+ if (cell.getCellType() == CellType.FORMULA) {
try {
evaluator.evaluateFormulaCell(cell);
} catch (Exception e) {
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java
index 9f90202e0f..fd815e9e03 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java
@@ -16,9 +16,8 @@
==================================================================== */
package org.apache.poi.xssf.usermodel;
-import junit.framework.TestCase;
-
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataConsolidateFunction;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Workbook;
@@ -30,6 +29,8 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotFields;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotTableDefinition;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STDataConsolidateFunction;
+import junit.framework.TestCase;
+
public class TestXSSFPivotTable extends TestCase {
private XSSFPivotTable pivotTable;
private XSSFPivotTable offsetPivotTable;
@@ -316,7 +317,7 @@ public class TestXSSFPivotTable extends TestCase {
*/
public void testAddDataColumnWithOffsetData() {
offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1);
- assertEquals(Cell.CELL_TYPE_NUMERIC, offsetOuterCell.getCellType());
+ assertEquals(CellType.NUMERIC, offsetOuterCell.getCellType());
offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 0);
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java
index c83336b7d6..9db9171e1e 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java
@@ -26,6 +26,7 @@ import java.io.IOException;
import org.apache.poi.ss.usermodel.BaseTestXRow;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellCopyPolicy;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.XSSFITestDataProvider;
@@ -182,7 +183,7 @@ public final class TestXSSFRow extends BaseTestXRow {
assertSame("existing references to externObserverRow are still valid", externObserverRow, sheet2.getRow(0));
// Make sure copyRowFrom actually copied row (this is tested elsewhere)
- assertEquals(Cell.CELL_TYPE_STRING, destRow.getCell(0).getCellType());
+ assertEquals(CellType.STRING, destRow.getCell(0).getCellType());
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
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
index 70df48c2df..f8681fd002 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
@@ -45,6 +45,7 @@ import org.apache.poi.ss.usermodel.AutoFilter;
import org.apache.poi.ss.usermodel.BaseTestXSheet;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellCopyPolicy;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.FormulaError;
import org.apache.poi.ss.usermodel.IgnoredErrorType;
@@ -1483,44 +1484,44 @@ public final class TestXSSFSheet extends BaseTestXSheet {
// Blank
cell = CellUtil.getCell(destRow, col++);
- assertEquals("[Blank] C7 cell type", Cell.CELL_TYPE_BLANK, cell.getCellType());
+ assertEquals("[Blank] C7 cell type", CellType.BLANK, cell.getCellType());
// Error
cell = CellUtil.getCell(destRow, col++);
- assertEquals("[Error] D7 cell type", Cell.CELL_TYPE_ERROR, cell.getCellType());
+ assertEquals("[Error] D7 cell type", CellType.ERROR, cell.getCellType());
final FormulaError error = FormulaError.forInt(cell.getErrorCellValue());
assertEquals("[Error] D7 cell value", FormulaError.NA, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here
// Date
cell = CellUtil.getCell(destRow, col++);
- assertEquals("[Date] E7 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+ assertEquals("[Date] E7 cell type", CellType.NUMERIC, cell.getCellType());
final Date date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 1).getTime();
assertEquals("[Date] E7 cell value", date, cell.getDateCellValue());
// Boolean
cell = CellUtil.getCell(destRow, col++);
- assertEquals("[Boolean] F7 cell type", Cell.CELL_TYPE_BOOLEAN, cell.getCellType());
+ assertEquals("[Boolean] F7 cell type", CellType.BOOLEAN, cell.getCellType());
assertEquals("[Boolean] F7 cell value", true, cell.getBooleanCellValue());
// String
cell = CellUtil.getCell(destRow, col++);
- assertEquals("[String] G7 cell type", Cell.CELL_TYPE_STRING, cell.getCellType());
+ assertEquals("[String] G7 cell type", CellType.STRING, cell.getCellType());
assertEquals("[String] G7 cell value", "Hello", cell.getStringCellValue());
// Int
cell = CellUtil.getCell(destRow, col++);
- assertEquals("[Int] H7 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+ assertEquals("[Int] H7 cell type", CellType.NUMERIC, cell.getCellType());
assertEquals("[Int] H7 cell value", 15, (int) cell.getNumericCellValue());
// Float
cell = CellUtil.getCell(destRow, col++);
- assertEquals("[Float] I7 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+ assertEquals("[Float] I7 cell type", CellType.NUMERIC, cell.getCellType());
assertEquals("[Float] I7 cell value", 12.5, cell.getNumericCellValue(), FLOAT_PRECISION);
// Cell Formula
cell = CellUtil.getCell(destRow, col++);
assertEquals("J7", new CellReference(cell).formatAsString());
- assertEquals("[Cell Formula] J7 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ assertEquals("[Cell Formula] J7 cell type", CellType.FORMULA, cell.getCellType());
assertEquals("[Cell Formula] J7 cell formula", "5+2", cell.getCellFormula());
System.out.println("Cell formula evaluation currently unsupported");
@@ -1529,21 +1530,21 @@ public final class TestXSSFSheet extends BaseTestXSheet {
cell = CellUtil.getCell(destRow, col++);
assertEquals("K7", new CellReference(cell).formatAsString());
assertEquals("[Cell Formula with Reference] K7 cell type",
- Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ CellType.FORMULA, cell.getCellType());
assertEquals("[Cell Formula with Reference] K7 cell formula",
"J7+H$2", cell.getCellFormula());
// Cell Formula with Reference spanning multiple rows
cell = CellUtil.getCell(destRow, col++);
assertEquals("[Cell Formula with Reference spanning multiple rows] L7 cell type",
- Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ CellType.FORMULA, cell.getCellType());
assertEquals("[Cell Formula with Reference spanning multiple rows] L7 cell formula",
"G7&\" \"&G8", cell.getCellFormula());
// Cell Formula with Reference spanning multiple rows
cell = CellUtil.getCell(destRow, col++);
assertEquals("[Cell Formula with Area Reference] M7 cell type",
- Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ CellType.FORMULA, cell.getCellType());
assertEquals("[Cell Formula with Area Reference] M7 cell formula",
"SUM(H7:I8)", cell.getCellFormula());
@@ -1552,13 +1553,13 @@ public final class TestXSSFSheet extends BaseTestXSheet {
System.out.println("Array formulas currently unsupported");
// FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula()
/*
- assertEquals("[Array Formula] N7 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ assertEquals("[Array Formula] N7 cell type", CellType.FORMULA, cell.getCellType());
assertEquals("[Array Formula] N7 cell formula", "{SUM(H7:J7*{1,2,3})}", cell.getCellFormula());
*/
// Data Format
cell = CellUtil.getCell(destRow, col++);
- assertEquals("[Data Format] O7 cell type;", Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+ assertEquals("[Data Format] O7 cell type;", CellType.NUMERIC, cell.getCellType());
assertEquals("[Data Format] O7 cell value", 100.20, cell.getNumericCellValue(), FLOAT_PRECISION);
//FIXME: currently fails
final String moneyFormat = "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)";
@@ -1637,83 +1638,83 @@ public final class TestXSSFSheet extends BaseTestXSheet {
// Blank
col++;
cell = CellUtil.getCell(destRow1, col);
- assertEquals("[Blank] C10 cell type", Cell.CELL_TYPE_BLANK, cell.getCellType());
+ assertEquals("[Blank] C10 cell type", CellType.BLANK, cell.getCellType());
cell = CellUtil.getCell(destRow2, col);
- assertEquals("[Blank] C11 cell type", Cell.CELL_TYPE_BLANK, cell.getCellType());
+ assertEquals("[Blank] C11 cell type", CellType.BLANK, cell.getCellType());
// Error
col++;
cell = CellUtil.getCell(destRow1, col);
- assertEquals("[Error] D10 cell type", Cell.CELL_TYPE_ERROR, cell.getCellType());
+ assertEquals("[Error] D10 cell type", CellType.ERROR, cell.getCellType());
FormulaError error = FormulaError.forInt(cell.getErrorCellValue());
assertEquals("[Error] D10 cell value", FormulaError.NA, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here
cell = CellUtil.getCell(destRow2, col);
- assertEquals("[Error] D11 cell type", Cell.CELL_TYPE_ERROR, cell.getCellType());
+ assertEquals("[Error] D11 cell type", CellType.ERROR, cell.getCellType());
error = FormulaError.forInt(cell.getErrorCellValue());
assertEquals("[Error] D11 cell value", FormulaError.NAME, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here
// Date
col++;
cell = CellUtil.getCell(destRow1, col);
- assertEquals("[Date] E10 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+ assertEquals("[Date] E10 cell type", CellType.NUMERIC, cell.getCellType());
Date date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 1).getTime();
assertEquals("[Date] E10 cell value", date, cell.getDateCellValue());
cell = CellUtil.getCell(destRow2, col);
- assertEquals("[Date] E11 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+ assertEquals("[Date] E11 cell type", CellType.NUMERIC, cell.getCellType());
date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 2).getTime();
assertEquals("[Date] E11 cell value", date, cell.getDateCellValue());
// Boolean
col++;
cell = CellUtil.getCell(destRow1, col);
- assertEquals("[Boolean] F10 cell type", Cell.CELL_TYPE_BOOLEAN, cell.getCellType());
+ assertEquals("[Boolean] F10 cell type", CellType.BOOLEAN, cell.getCellType());
assertEquals("[Boolean] F10 cell value", true, cell.getBooleanCellValue());
cell = CellUtil.getCell(destRow2, col);
- assertEquals("[Boolean] F11 cell type", Cell.CELL_TYPE_BOOLEAN, cell.getCellType());
+ assertEquals("[Boolean] F11 cell type", CellType.BOOLEAN, cell.getCellType());
assertEquals("[Boolean] F11 cell value", false, cell.getBooleanCellValue());
// String
col++;
cell = CellUtil.getCell(destRow1, col);
- assertEquals("[String] G10 cell type", Cell.CELL_TYPE_STRING, cell.getCellType());
+ assertEquals("[String] G10 cell type", CellType.STRING, cell.getCellType());
assertEquals("[String] G10 cell value", "Hello", cell.getStringCellValue());
cell = CellUtil.getCell(destRow2, col);
- assertEquals("[String] G11 cell type", Cell.CELL_TYPE_STRING, cell.getCellType());
+ assertEquals("[String] G11 cell type", CellType.STRING, cell.getCellType());
assertEquals("[String] G11 cell value", "World", cell.getStringCellValue());
// Int
col++;
cell = CellUtil.getCell(destRow1, col);
- assertEquals("[Int] H10 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+ assertEquals("[Int] H10 cell type", CellType.NUMERIC, cell.getCellType());
assertEquals("[Int] H10 cell value", 15, (int) cell.getNumericCellValue());
cell = CellUtil.getCell(destRow2, col);
- assertEquals("[Int] H11 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+ assertEquals("[Int] H11 cell type", CellType.NUMERIC, cell.getCellType());
assertEquals("[Int] H11 cell value", 42, (int) cell.getNumericCellValue());
// Float
col++;
cell = CellUtil.getCell(destRow1, col);
- assertEquals("[Float] I10 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+ assertEquals("[Float] I10 cell type", CellType.NUMERIC, cell.getCellType());
assertEquals("[Float] I10 cell value", 12.5, cell.getNumericCellValue(), FLOAT_PRECISION);
cell = CellUtil.getCell(destRow2, col);
- assertEquals("[Float] I11 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+ assertEquals("[Float] I11 cell type", CellType.NUMERIC, cell.getCellType());
assertEquals("[Float] I11 cell value", 5.5, cell.getNumericCellValue(), FLOAT_PRECISION);
// Cell Formula
col++;
cell = CellUtil.getCell(destRow1, col);
- assertEquals("[Cell Formula] J10 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ assertEquals("[Cell Formula] J10 cell type", CellType.FORMULA, cell.getCellType());
assertEquals("[Cell Formula] J10 cell formula", "5+2", cell.getCellFormula());
cell = CellUtil.getCell(destRow2, col);
- assertEquals("[Cell Formula] J11 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ assertEquals("[Cell Formula] J11 cell type", CellType.FORMULA, cell.getCellType());
assertEquals("[Cell Formula] J11 cell formula", "6+18", cell.getCellFormula());
// Cell Formula with Reference
@@ -1721,25 +1722,25 @@ public final class TestXSSFSheet extends BaseTestXSheet {
// Formula row references should be adjusted by destRowNum-srcRowNum
cell = CellUtil.getCell(destRow1, col);
assertEquals("[Cell Formula with Reference] K10 cell type",
- Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ CellType.FORMULA, cell.getCellType());
assertEquals("[Cell Formula with Reference] K10 cell formula",
"J10+H$2", cell.getCellFormula());
cell = CellUtil.getCell(destRow2, col);
- assertEquals("[Cell Formula with Reference] K11 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ assertEquals("[Cell Formula with Reference] K11 cell type", CellType.FORMULA, cell.getCellType());
assertEquals("[Cell Formula with Reference] K11 cell formula", "J11+H$2", cell.getCellFormula());
// Cell Formula with Reference spanning multiple rows
col++;
cell = CellUtil.getCell(destRow1, col);
assertEquals("[Cell Formula with Reference spanning multiple rows] L10 cell type",
- Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ CellType.FORMULA, cell.getCellType());
assertEquals("[Cell Formula with Reference spanning multiple rows] L10 cell formula",
"G10&\" \"&G11", cell.getCellFormula());
cell = CellUtil.getCell(destRow2, col);
assertEquals("[Cell Formula with Reference spanning multiple rows] L11 cell type",
- Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ CellType.FORMULA, cell.getCellType());
assertEquals("[Cell Formula with Reference spanning multiple rows] L11 cell formula",
"G11&\" \"&G12", cell.getCellFormula());
@@ -1747,13 +1748,13 @@ public final class TestXSSFSheet extends BaseTestXSheet {
col++;
cell = CellUtil.getCell(destRow1, col);
assertEquals("[Cell Formula with Area Reference] M10 cell type",
- Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ CellType.FORMULA, cell.getCellType());
assertEquals("[Cell Formula with Area Reference] M10 cell formula",
"SUM(H10:I11)", cell.getCellFormula());
cell = CellUtil.getCell(destRow2, col);
assertEquals("[Cell Formula with Area Reference] M11 cell type",
- Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ CellType.FORMULA, cell.getCellType());
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
@@ -1763,19 +1764,19 @@ public final class TestXSSFSheet extends BaseTestXSheet {
// System.out.println("Array formulas currently unsupported");
/*
// FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula()
- assertEquals("[Array Formula] N10 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ assertEquals("[Array Formula] N10 cell type", CellType.FORMULA, cell.getCellType());
assertEquals("[Array Formula] N10 cell formula", "{SUM(H10:J10*{1,2,3})}", cell.getCellFormula());
cell = CellUtil.getCell(destRow2, col);
// FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula()
- assertEquals("[Array Formula] N11 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType());
+ assertEquals("[Array Formula] N11 cell type", CellType.FORMULA, cell.getCellType());
assertEquals("[Array Formula] N11 cell formula", "{SUM(H11:J11*{1,2,3})}", cell.getCellFormula());
*/
// Data Format
col++;
cell = CellUtil.getCell(destRow2, col);
- assertEquals("[Data Format] O10 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+ assertEquals("[Data Format] O10 cell type", CellType.NUMERIC, cell.getCellType());
assertEquals("[Data Format] O10 cell value", 100.20, cell.getNumericCellValue(), FLOAT_PRECISION);
final String moneyFormat = "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)";
assertEquals("[Data Format] O10 cell data format", moneyFormat, cell.getCellStyle().getDataFormatString());
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java
index a527dbec15..24f9e37b29 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java
@@ -26,6 +26,7 @@ import java.io.IOException;
import org.apache.poi.ss.usermodel.BaseTestSheetShiftRows;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Comment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
@@ -116,7 +117,7 @@ public final class TestXSSFSheetShiftRows extends BaseTestSheetShiftRows {
return;
}
Cell readCell = readRow.getCell(0);
- if(readCell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
+ if(readCell.getCellType() == CellType.NUMERIC) {
assertEquals(expect, Double.toString(readCell.getNumericCellValue()));
} else {
assertEquals(expect, readCell.getStringCellValue());