]> source.dussan.org Git - poi.git/commitdiff
bug 59791: replace deprecated Cell.CELL_TYPE_* usage with CellType.*
authorJaven O'Neal <onealj@apache.org>
Mon, 4 Jul 2016 10:15:18 +0000 (10:15 +0000)
committerJaven O'Neal <onealj@apache.org>
Mon, 4 Jul 2016 10:15:18 +0000 (10:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751240 13f79535-47bb-0310-9956-ffa450edef68

81 files changed:
src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java
src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java
src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java
src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java
src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java
src/examples/src/org/apache/poi/ss/examples/ToCSV.java
src/java/org/apache/poi/hssf/record/RecordInputStream.java
src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java
src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
src/java/org/apache/poi/ss/format/CellFormat.java
src/java/org/apache/poi/ss/formula/EvaluationCache.java
src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java
src/java/org/apache/poi/ss/formula/eval/RefEval.java
src/java/org/apache/poi/ss/usermodel/Cell.java
src/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java
src/java/org/apache/poi/ss/usermodel/charts/DataSources.java
src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java
src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java
src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java
src/ooxml/testcases/org/apache/poi/ss/formula/TestStructuredReferences.java
src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestProper.java
src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java
src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java
src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java
src/scratchpad/src/org/apache/poi/hwpf/QuickTest.java
src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java
src/testcases/org/apache/poi/hssf/model/TestRVA.java
src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java
src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java
src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java
src/testcases/org/apache/poi/hssf/usermodel/TestExternalReferenceChange.java
src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java
src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java
src/testcases/org/apache/poi/ss/format/TestCellFormat.java
src/testcases/org/apache/poi/ss/formula/BaseTestExternalFunctions.java
src/testcases/org/apache/poi/ss/formula/TestEvaluationCache.java
src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java
src/testcases/org/apache/poi/ss/formula/atp/TestIfError.java
src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java
src/testcases/org/apache/poi/ss/formula/atp/TestYearFracCalculatorFromSpreadsheet.java
src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java
src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java
src/testcases/org/apache/poi/ss/formula/eval/TestPercentEval.java
src/testcases/org/apache/poi/ss/formula/functions/CountifsTests.java
src/testcases/org/apache/poi/ss/formula/functions/TestAddress.java
src/testcases/org/apache/poi/ss/formula/functions/TestCalendarFieldFunction.java
src/testcases/org/apache/poi/ss/formula/functions/TestClean.java
src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java
src/testcases/org/apache/poi/ss/formula/functions/TestDate.java
src/testcases/org/apache/poi/ss/formula/functions/TestFind.java
src/testcases/org/apache/poi/ss/formula/functions/TestFixed.java
src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java
src/testcases/org/apache/poi/ss/formula/functions/TestIrr.java
src/testcases/org/apache/poi/ss/formula/functions/TestIsBlank.java
src/testcases/org/apache/poi/ss/formula/functions/TestLogicalFunction.java
src/testcases/org/apache/poi/ss/formula/functions/TestMirr.java
src/testcases/org/apache/poi/ss/formula/functions/TestNper.java
src/testcases/org/apache/poi/ss/formula/udf/TestAggregatingUDFFinder.java
src/testcases/org/apache/poi/ss/formula/udf/TestDefaultUDFFinder.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java
src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java
src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java

index 07b9b0165a2e308d72e4d8657660b7ea96a970be..3e31d11f2675eb3a9857ca60ce38a96d0d458c57 100644 (file)
 
 package org.apache.poi.hssf.usermodel.examples;
 
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Date;
 
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.CellType;
+
 public class CellTypes {
     public static void main(String[] args) throws IOException {
         HSSFWorkbook wb = new HSSFWorkbook();
@@ -35,7 +35,7 @@ public class CellTypes {
         row.createCell(1).setCellValue(new Date());
         row.createCell(2).setCellValue("a string");
         row.createCell(3).setCellValue(true);
-        row.createCell(4).setCellType(HSSFCell.CELL_TYPE_ERROR);
+        row.createCell(4).setCellType(CellType.ERROR);
 
         // Write the output to a file
         FileOutputStream fileOut = new FileOutputStream("workbook.xls");
index 8ed9213bfaf47565cb7a58aefca30d49c0b73669..148b2a58b0d7fe87bbc968ad52fb4d66bd4a94ea 100644 (file)
 
 package org.apache.poi.hssf.usermodel.examples;
 
-import org.apache.poi.hssf.usermodel.*;
-
 import java.io.FileOutputStream;
 import java.io.IOException;
 
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.CellType;
+
 /**
  * Test if hyperlink formula, with url that got more than 127 characters, works
  *
@@ -34,7 +38,7 @@ public class HyperlinkFormula {
         HSSFRow row = sheet.createRow(0);
 
         HSSFCell cell = row.createCell(0);
-        cell.setCellType(HSSFCell.CELL_TYPE_FORMULA);
+        cell.setCellType(CellType.FORMULA);
         cell.setCellFormula("HYPERLINK(\"http://127.0.0.1:8080/toto/truc/index.html?test=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", \"test\")");
 
         FileOutputStream fileOut = new FileOutputStream("workbook.xls");
index 7653a0b527b57f4749bff75dd336b1e702ba4cfd..018556f991f0b80adcaced403363b43eb3db24f4 100644 (file)
@@ -18,6 +18,7 @@
 package org.apache.poi.hssf.usermodel.examples;
 
 import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ss.usermodel.CellType;
 
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -47,7 +48,7 @@ public class NewLinesInCells {
                r = s.createRow(2);
                r.setHeight((short) 0x349);
                c = r.createCell(2);
-               c.setCellType(HSSFCell.CELL_TYPE_STRING);
+               c.setCellType(CellType.STRING);
                c.setCellValue("Use \n with word wrap on to create a new line");
                c.setCellStyle(cs);
                s.setColumnWidth(2, (int) ((50 * 8) / ((double) 1 / 20)));
index 26bba44674d30310bd8ca82b564f49160d29d30d..2b3553f768de73851b7c4408cf812bd0fa437ae1 100644 (file)
 
 package org.apache.poi.hssf.usermodel.examples;
 
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFCell;
-
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.ss.usermodel.CellType;
+
 /**
  * This example demonstrates opening a workbook, modifying it and writing
  * the results back out.
@@ -50,7 +51,7 @@ public class ReadWriteWorkbook {
             HSSFCell cell = row.getCell(3);
             if (cell == null)
                 cell = row.createCell(3);
-            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
+            cell.setCellType(CellType.STRING);
             cell.setCellValue("a test");
 
             // Write the output to a file
index caace28f7fe387c76c99259ddc03b03c8a100bab..b33d8cba10e98120c664b5b31d67f05c201e33b7 100644 (file)
 ==================================================================== */
 package org.apache.poi.hssf.view;
 
-import org.apache.poi.hssf.view.brush.PendingPaintings;
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.Row;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.Toolkit;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
 
-import javax.swing.*;
+import javax.swing.BorderFactory;
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JViewport;
+import javax.swing.ListSelectionModel;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
-import javax.swing.table.*;
+import javax.swing.table.JTableHeader;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
+import javax.swing.table.TableModel;
 import javax.swing.text.JTextComponent;
-import java.awt.*;
-import java.awt.event.HierarchyEvent;
-import java.awt.event.HierarchyListener;
+
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.view.brush.PendingPaintings;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.Row;
 
 /**
  * This class is a table that represents the values in a single worksheet.
@@ -125,7 +142,7 @@ public class SVSheetTable extends JTable {
       HSSFCell cell = (HSSFCell) getValueAt(row, col);
       String formula = "";
       if (cell != null) {
-        if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
+        if (cell.getCellType() == CellType.FORMULA) {
           formula = cell.getCellFormula();
         } else {
           formula = cell.toString();
index 67b6d56a6dc44c0c80fa93ff753e94935a2dac29..616f838706e0799831055558d1ee3ded7667bba4 100644 (file)
@@ -29,6 +29,7 @@ import java.util.ArrayList;
 
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.DataFormatter;
 import org.apache.poi.ss.usermodel.FormulaEvaluator;
 import org.apache.poi.ss.usermodel.Row;
@@ -541,7 +542,7 @@ public class ToCSV {
                     csvLine.add("");
                 }
                 else {
-                    if(cell.getCellType() != Cell.CELL_TYPE_FORMULA) {
+                    if(cell.getCellType() != CellType.FORMULA) {
                         csvLine.add(this.formatter.formatCellValue(cell));
                     }
                     else {
index 2b66bd80a3df55d4aff07315c547a19fd1bdd6a7..81ec0776b3679a48283da0a5c34bf476a71ca5e3 100644 (file)
@@ -283,10 +283,10 @@ public final class RecordInputStream implements LittleEndianInput {
                long valueLongBits = readLong();
                double result = Double.longBitsToDouble(valueLongBits);
                if (Double.isNaN(result)) {
-            // YK: Excel doesn't write NaN but instead converts the cell type into CELL_TYPE_ERROR.
+            // YK: Excel doesn't write NaN but instead converts the cell type into {@link CellType#ERROR}.
             // HSSF prior to version 3.7 had a bug: it could write Double.NaN but could not read such a file back.
             // This behavior was fixed in POI-3.7.
-            //throw new RuntimeException("Did not expect to read NaN"); // (Because Excel typically doesn't write NaN
+            //throw new RuntimeException("Did not expect to read NaN"); // (Because Excel typically doesn't write NaN)
                }
                return result;
        }
index 238b89ed39537aa7539ed0ac477f68337e875207..347300d5f47805e4e92c68fb1816b89175c55520 100644 (file)
@@ -22,6 +22,7 @@ import org.apache.poi.hssf.record.ExtendedFormatRecord;
 import org.apache.poi.hssf.record.FontRecord;
 import org.apache.poi.hssf.record.common.UnicodeString;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.Row;
 
 /**
@@ -141,7 +142,7 @@ public class HSSFOptimiser {
                        HSSFSheet s = workbook.getSheetAt(sheetNum);
                        for (Row row : s) {
                           for (Cell cell : row) {
-                                       if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
+                                       if(cell.getCellType() == CellType.STRING) {
                                                HSSFRichTextString rtr = (HSSFRichTextString)cell.getRichStringCellValue();
                                                UnicodeString u = rtr.getRawUnicodeString();
                                                
index ba4c7b58c9129e8b3fb676247bdec12b39513a5c..f67de61271b3e61eb4b034df7cf5de0cd54a99db 100644 (file)
@@ -99,7 +99,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
     /**
      * Use this to create new cells within the row and return it.
      * <p>
-     * The cell that is returned is a CELL_TYPE_BLANK. The type can be changed
+     * The cell that is returned is a {@link CellType#BLANK}. The type can be changed
      * either through calling <code>setCellValue</code> or <code>setCellType</code>.
      *
      * @param column - the column number this cell represents
index 037c6b754859e16ab1337ba7f27661a96d7675d1..698e20a06e096cdc1e74c5f9a4912ef7507c74a1 100644 (file)
@@ -40,7 +40,6 @@ import org.apache.poi.hssf.record.EscherAggregate;
 import org.apache.poi.hssf.record.ExtendedFormatRecord;
 import org.apache.poi.hssf.record.HyperlinkRecord;
 import org.apache.poi.hssf.record.NameRecord;
-import org.apache.poi.hssf.record.NoteRecord;
 import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.record.RecordBase;
 import org.apache.poi.hssf.record.RowRecord;
@@ -62,6 +61,7 @@ import org.apache.poi.ss.formula.ptg.UnionPtg;
 import org.apache.poi.ss.usermodel.Cell;
 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.Row;
@@ -2338,7 +2338,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
         CellRange<HSSFCell> result = getCellRange(range);
         // clear all cells in the range
         for (Cell c : result) {
-            c.setCellType(Cell.CELL_TYPE_BLANK);
+            c.setCellType(CellType.BLANK);
         }
         return result;
     }
index df60021dd63e795dafb5d1a7c3c26dc7567c88ca..5775fd3b2ed2542b2db71afe0650d91deec9b704 100644 (file)
@@ -410,7 +410,7 @@ public class CellFormat {
 
     /**
      * Returns the ultimate cell type, following the results of formulas.  If
-     * the cell is a {@link Cell#CELL_TYPE_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
      * result of {@link Cell#getCellType()}.
      *
index 6b9278e3c550e7893e85692587cf90e60b7e5859..ff655f36bbd27556d2dfcb39c977bff21329af93 100644 (file)
 
 package org.apache.poi.ss.formula;
 
+import org.apache.poi.ss.formula.FormulaCellCache.IEntryOperation;
+import org.apache.poi.ss.formula.FormulaUsedBlankCellSet.BookSheetKey;
+import org.apache.poi.ss.formula.PlainCellCache.Loc;
 import org.apache.poi.ss.formula.eval.BlankEval;
 import org.apache.poi.ss.formula.eval.BoolEval;
 import org.apache.poi.ss.formula.eval.ErrorEval;
 import org.apache.poi.ss.formula.eval.NumberEval;
 import org.apache.poi.ss.formula.eval.StringEval;
 import org.apache.poi.ss.formula.eval.ValueEval;
-import org.apache.poi.ss.formula.FormulaCellCache.IEntryOperation;
-import org.apache.poi.ss.formula.FormulaUsedBlankCellSet.BookSheetKey;
-import org.apache.poi.ss.formula.PlainCellCache.Loc;
-import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 
 /**
  * Performance optimisation for {@link org.apache.poi.ss.usermodel.FormulaEvaluator}.
@@ -56,7 +56,7 @@ final class EvaluationCache {
                Loc loc = new Loc(bookIndex, sheetIndex, rowIndex, columnIndex);
                PlainValueCellCacheEntry pcce = _plainCellCache.get(loc);
 
-               if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
+               if (cell.getCellType() == CellType.FORMULA) {
                        if (fcce == null) {
                                fcce = new FormulaCellCacheEntry();
                                if (pcce == null) {
@@ -197,7 +197,7 @@ final class EvaluationCache {
        }
        public void notifyDeleteCell(int bookIndex, int sheetIndex, EvaluationCell cell) {
 
-               if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
+               if (cell.getCellType() == CellType.FORMULA) {
                        FormulaCellCacheEntry fcce = _formulaCellCache.remove(cell);
                        if (fcce == null) {
                                // formula cell has not been evaluated yet
index bc4c8626207202d3668ca2d983323d80c362b0c1..c9b408fa51f1d4b5dba9f2bbdf5fe18e08fc309c 100644 (file)
@@ -20,7 +20,7 @@ package org.apache.poi.ss.formula;
 import org.apache.poi.ss.formula.eval.ValueEval;
 import org.apache.poi.ss.formula.ptg.FuncVarPtg;
 import org.apache.poi.ss.formula.ptg.Ptg;
-import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 
 /**
  * Evaluator for cells within a specific Sheet
@@ -62,7 +62,7 @@ final class SheetRefEvaluator {
     public boolean isSubTotal(int rowIndex, int columnIndex){
         boolean subtotal = false;
         EvaluationCell cell = getSheet().getCell(rowIndex, columnIndex);
-        if(cell != null && cell.getCellType() == Cell.CELL_TYPE_FORMULA){
+        if(cell != null && cell.getCellType() == CellType.FORMULA){
             EvaluationWorkbook wb = _bookEvaluator.getWorkbook();
             for(Ptg ptg : wb.getFormulaTokens(cell)){
                 if(ptg instanceof FuncVarPtg){
index c8e0296fe24ed23f7fd90a7ed4d9c894c70094c2..46aa96c04cf727fc5b58ae081c0a7d3e535b3807 100644 (file)
 package org.apache.poi.ss.formula.eval;
 
 import org.apache.poi.ss.formula.SheetRange;
+import org.apache.poi.ss.usermodel.CellType;
 
 /**
  * RefEval is the super interface for Ref2D and Ref3DEval. Basically a RefEval
  * impl should contain reference to the original ReferencePtg or Ref3DPtg as
  * well as the final "value" resulting from the evaluation of the cell
- * reference. Thus if the Cell has type CELL_TYPE_NUMERIC, the contained
- * value object should be of type NumberEval; if cell type is CELL_TYPE_STRING,
+ * reference. Thus if the Cell has type {@link CellType#NUMERIC}, the contained
+ * value object should be of type NumberEval; if cell type is {@link CellType#STRING},
  * contained value object should be of type StringEval
  */
 public interface RefEval extends ValueEval, SheetRange {
index be663895430d40b4be06aa2ff5a0c9b3de95da1e..0191b159dd89cd2d42d22ac00d4bb8846f5e8740 100644 (file)
@@ -127,12 +127,12 @@ public interface Cell {
      *
      * @throws IllegalArgumentException if the specified cell type is invalid
      * @throws IllegalStateException if the current value cannot be converted to the new type
-     * @see #CELL_TYPE_NUMERIC
-     * @see #CELL_TYPE_STRING
-     * @see #CELL_TYPE_FORMULA
-     * @see #CELL_TYPE_BLANK
-     * @see #CELL_TYPE_BOOLEAN
-     * @see #CELL_TYPE_ERROR
+     * @see CellType#NUMERIC
+     * @see CellType#STRING
+     * @see CellType#FORMULA
+     * @see CellType#BLANK
+     * @see CellType#BOOLEAN
+     * @see CellType#ERROR
      * @deprecated POI 3.15 beta 3. Use {@link #setCellType(CellType)} instead.
      */
     void setCellType(int cellType);
index 1f7c8fd8335e2074151bc3ea2e4ccfca6a6d7db6..b68a729a26b4a3c076b333fb8f5d4369e88d4669 100644 (file)
@@ -96,8 +96,8 @@ public interface FormulaEvaluator {
      *  the result of the formula, use {@link #evaluateInCell(Cell)}
      * @param cell The cell to evaluate
      * @return The type of the formula result, i.e. -1 if the cell is not a formula, 
-     *      or one of Cell.CELL_TYPE_NUMERIC, Cell.CELL_TYPE_STRING, Cell.CELL_TYPE_BOOLEAN, Cell.CELL_TYPE_ERROR
-     *      Note: the cell's type remains as Cell.CELL_TYPE_FORMULA however.
+     *      or one of CellType.NUMERIC, CellType.STRING, CellType.BOOLEAN, CellType.ERROR
+     *      Note: the cell's type remains as CellType.FORMULA however.
      */
     CellType evaluateFormulaCell(Cell cell);
 
index 2f443814ee2a8db52e59f5754817d06113f6158d..3bf891e0a9ca2ced7d01c4ab924881a77dad357c 100644 (file)
@@ -42,7 +42,7 @@ public class DataSources {
         return new AbstractCellRangeDataSource<Number>(sheet, cellRangeAddress) {
             public Number getPointAt(int index) {
                 CellValue cellValue = getCellValueAt(index);
-                if (cellValue != null && cellValue.getCellType() == Cell.CELL_TYPE_NUMERIC) {
+                if (cellValue != null && cellValue.getCellType() == CellType.NUMERIC) {
                     return Double.valueOf(cellValue.getNumberValue());
                 } else {
                     return null;
@@ -59,7 +59,7 @@ public class DataSources {
         return new AbstractCellRangeDataSource<String>(sheet, cellRangeAddress) {
             public String getPointAt(int index) {
                 CellValue cellValue = getCellValueAt(index);
-                if (cellValue != null && cellValue.getCellType() == Cell.CELL_TYPE_STRING) {
+                if (cellValue != null && cellValue.getCellType() == CellType.STRING) {
                     return cellValue.getStringValue();
                 } else {
                     return null;
index 667fb03c531cfc306c8407c602b1226fb980e26a..c72048ec26d693b0da64b84a2f049613026ffa37 100644 (file)
@@ -18,6 +18,7 @@
 package org.apache.poi.ss.util.cellwalk;
 
 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.CellRangeAddress;
@@ -100,7 +101,7 @@ public class CellWalk {
     }
 
     private boolean isEmpty(Cell cell) {
-        return (cell.getCellType() == Cell.CELL_TYPE_BLANK);
+        return (cell.getCellType() == CellType.BLANK);
     }
 
     /**
index 3415af301094bda5e4db701028cc2d92ae8e9a06..965534f34bcb4b345fc7c2087de6f07bcb82ede8 100644 (file)
@@ -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);
                     }
                 }
index 81359d3857f3961b342be14d74def1b587dd8226..6d337f44652c19db9030508c69b6dbed9801568e 100644 (file)
@@ -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) {
index c611e13e3815d670b9d9cf5c4af69d7130b98d14..8ab465aff1daca6035da56ac50e772a262c265b5 100644 (file)
@@ -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();
         }
index d0e9d1a8ce62706efd31145656eb8a09d8c4a115..9f686491992c3f29fbf787e3e96893d6bcfa690d 100644 (file)
@@ -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());
index 3ae3d5b579691b24ba399dfa2a35cd391ee6a7a2..efd45943fa99e6d428d7591f172f8899f50d0513 100644 (file)
@@ -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;
             }
index 99e8a1e40832b1ef62125b54bdc672e2a9a8c83f..107e205b98c8c164052e4074352541a8c722ec57 100644 (file)
@@ -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);
                     }
                 }
index a21ad32a0566bef1606772a4e1b99b4bf4dca734..fd598a479b300d71992e52701bd2bda4e19c2fec 100644 (file)
@@ -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);
index cac071f4166c0cbc5343fa64b894e323e60fdfb8..40500480a6a4b523ab7f0f9f2519e747739dd760 100644 (file)
@@ -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();
index ccc883dd30509ada8694f799e54ad704a1df906b..b36b86773653d318d02c5bed2c7760f6fe71cc77 100644 (file)
@@ -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()) {
index 0932177e000aebf2dd5c754155c53912a8659a5d..42cf2714a5c20bbf5f0f06c43a3bdbe73a96999a 100644 (file)
 
 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());
     }
 
 
index 4fbdbcd6e9291ae01466c26515c618eff315713c..67ebe1ef00450c145c51d59d9362e9ff06b5bf43 100644 (file)
@@ -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;
             }
         }
index b9c5c9809a8a5f600ab03f4e16dea6148494a6fe..8c6951de18032b9775a1838407a4b3390a2d8a5c 100644 (file)
@@ -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());
     }
     
index 8be5121426edcd9ff3be0f2478f13aa20d607ae8..d9cbec5dd161d048015287fc1d409603a2b7183e 100644 (file)
@@ -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());
                                
                                
index 87475771bda2cd00974b09f1844090fed2fdfb2e..28cc7f79a3f2ca53a8e25ba17d5e69a35a0ee3ed 100644 (file)
@@ -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);
     }
 
index 08c4ed29849e1316ee4fbcec858bb554216f5376..119157f68261fe59146dab51bfaf43459c17f685 100644 (file)
@@ -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) {
index 9f90202e0fb1f6e17522b5b7eca4e6c8feb7e06c..fd815e9e03186154573c366dd1e01ad36cacb1af 100644 (file)
@@ -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);
     }
index c83336b7d6d7261473573530e7e2796b6c354aae..9db9171e1e0eef27dd89439b02ccafac425cf45e 100644 (file)
@@ -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
index 70df48c2dfdcc287479bd1c337927f05eaae0ff1..f8681fd002fd733baf2b7c8bcebd364dabd701d3 100644 (file)
@@ -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());
index a527dbec15cc42a86838400ebd06811586f0a77b..24f9e37b29ecea72df6d376788ef8638d4cc5e94 100644 (file)
@@ -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());
index ec97cb4c10b50f84c3af2e8893e92d4110055f1d..eeb17abe3b64dea688e0e21918275179252e83f7 100644 (file)
@@ -18,7 +18,6 @@
 package org.apache.poi.hwpf;
 
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 
 import org.apache.poi.hwpf.usermodel.CharacterRun;
index 7fd2850df94a3cd4acce53813783d8b998aabe2c..53f5f4ac75660818dc2505a96efe8bd0adee87f9 100644 (file)
@@ -30,6 +30,7 @@ import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.formula.FormulaParseException;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
 
 /**
@@ -98,7 +99,7 @@ public final class TestFormulaParserEval extends TestCase {
                        }
                        throw e;
                }
-               assertEquals(HSSFCell.CELL_TYPE_NUMERIC, result.getCellType());
+               assertEquals(CellType.NUMERIC, result.getCellType());
                assertEquals(42.0, result.getNumberValue(), 0.0);
        }
 }
index e1345c2e9d892283968f4f803f11a949ea702ff2..48d0066cf00090c432ec40a092981492768adc0f 100644 (file)
@@ -33,6 +33,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.ss.formula.ptg.AttrPtg;
 import org.apache.poi.ss.formula.ptg.Ptg;
+import org.apache.poi.ss.usermodel.CellType;
 import org.junit.AfterClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -79,7 +80,7 @@ public final class TestRVA {
                 break;
             }
             HSSFCell cell = row.getCell(0);
-            if (cell == null || cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
+            if (cell == null || cell.getCellType() == CellType.BLANK) {
                 break;
             }
 
index 14de4bcdafff2d878104211177e81aa81e375c38..bf7b813d0a0e429fb00ac385dfd5401237af5046 100644 (file)
@@ -26,6 +26,7 @@ import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.formula.ptg.RefPtg;
 import org.apache.poi.ss.formula.SharedFormula;
 import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
 import org.apache.poi.ss.formula.FormulaParser;
 import org.apache.poi.ss.formula.FormulaRenderer;
@@ -203,7 +204,7 @@ public final class TestSharedFormulaRecord extends TestCase {
 
         assertEquals("A$1*2", sheet.getRow(ROW_IX).getCell(1).getCellFormula());
         cell = sheet.getRow(ROW_IX).getCell(1);
-        cell.setCellType(HSSFCell.CELL_TYPE_BLANK);
+        cell.setCellType(CellType.BLANK);
         assertEquals(3, countSharedFormulas(sheet));
 
         wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
@@ -227,7 +228,7 @@ public final class TestSharedFormulaRecord extends TestCase {
     private static void confirmCellEvaluation(HSSFWorkbook wb, HSSFCell cell, double expectedValue) {
         HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
         CellValue cv = fe.evaluate(cell);
-        assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType());
+        assertEquals(CellType.NUMERIC, cv.getCellType());
         assertEquals(expectedValue, cv.getNumberValue(), 0.0);
     }
 
index 6fdfb0fe33a636bc497097b8bccf09add0b96ce2..f0f95261a7ddacdc79925d0dce17648b8063f343 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
 import org.apache.poi.hssf.util.CellReference;
 import org.apache.poi.ss.formula.ptg.Ptg;
 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.Row;
 import org.junit.Test;
@@ -67,7 +68,7 @@ public final class TestBug42464 {
                Iterator<Cell> it = row.cellIterator();
                while(it.hasNext()) {
                        HSSFCell cell = (HSSFCell)it.next();
-                       if(cell.getCellType() != HSSFCell.CELL_TYPE_FORMULA) {
+                       if(cell.getCellType() != CellType.FORMULA) {
                            continue;
                        }
                        FormulaRecordAggregate record = (FormulaRecordAggregate) cell.getCellValueRecord();
index cba7a6615edaa96f7997a0964fbc17b309c26b5a..e5aad2afc4d61e81e1d4355e01b1451fed11bd5f 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.ss.usermodel.BorderStyle;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.Font;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -435,7 +436,7 @@ public final class TestCellStyle extends TestCase {
         
                             Cell cell = row.getCell(idxCell);
                             cell.getCellStyle().getDataFormatString();
-                            if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
+                            if (cell.getCellType() == CellType.NUMERIC) {
                                 boolean isDate = HSSFDateUtil.isCellDateFormatted(cell);
                                 if (idxCell > 0 && isDate) {
                                     fail("cell " + idxCell + " is not a date: " + idxCell.toString());
index 87408b9f598d50f14d589cc81f45fe5655e6c722..86d59d8c7429e6885847c0c8cac7e5225898aa16 100644 (file)
@@ -19,7 +19,7 @@ package org.apache.poi.hssf.usermodel;
 import java.io.IOException;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 
 import junit.framework.TestCase;
 
@@ -51,7 +51,7 @@ public class TestExternalReferenceChange extends TestCase {
                HSSFSheet lSheet = mainWorkbook.getSheetAt(0);
                HSSFCell lA1Cell = lSheet.getRow(0).getCell(0);
                
-               assertEquals(Cell.CELL_TYPE_FORMULA, lA1Cell.getCellType());
+               assertEquals(CellType.FORMULA, lA1Cell.getCellType());
                
                HSSFFormulaEvaluator lMainWorkbookEvaluator = new HSSFFormulaEvaluator(mainWorkbook);
                HSSFFormulaEvaluator lSourceEvaluator = new HSSFFormulaEvaluator(sourceWorkbook);
@@ -59,7 +59,7 @@ public class TestExternalReferenceChange extends TestCase {
                                new String[]{MAIN_WORKBOOK_FILENAME, SOURCE_WORKBOOK_FILENAME}, 
                                new HSSFFormulaEvaluator[] {lMainWorkbookEvaluator, lSourceEvaluator});
                
-               assertEquals(Cell.CELL_TYPE_NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCell(lA1Cell));
+               assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCell(lA1Cell));
 
                assertEquals(20.0d, lA1Cell.getNumericCellValue(), 0.00001d);
 
index eb59e8a7517523c7f12de576d22f482dd751684d..82124ffc803bb2cb3580367bc35bf18c7be76b30 100644 (file)
@@ -40,6 +40,7 @@ import org.apache.poi.ss.formula.ptg.FuncVarPtg;
 import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.formula.ptg.RefPtg;
 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.util.CellReference;
 import org.apache.poi.util.LocaleUtil;
@@ -565,7 +566,7 @@ public final class TestFormulaEvaluatorBugs {
         }
     }
     private Ptg[] getPtgs(HSSFCell cell) {
-        assertEquals(HSSFCell.CELL_TYPE_FORMULA, cell.getCellType());
+        assertEquals(CellType.FORMULA, cell.getCellType());
         assertEquals(FormulaRecordAggregate.class, cell.getCellValueRecord().getClass());
         FormulaRecordAggregate agg = (FormulaRecordAggregate)cell.getCellValueRecord();
         FormulaRecord rec = agg.getFormulaRecord();
index d2c9d0753cd8a56462f5580505d9df2f90c7ca59..902884653d6f0b50da57df1d82e413bee141ec90 100644 (file)
@@ -19,6 +19,8 @@ package org.apache.poi.hssf.usermodel;
 
 import java.util.Iterator;
 
+import org.apache.poi.ss.usermodel.CellType;
+
 import junit.framework.TestCase;
 
 /**
@@ -75,11 +77,11 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
 
                                for(Iterator cit = r.cellIterator(); cit.hasNext();) {
                                        HSSFCell c = (HSSFCell)cit.next();
-                                       if(c.getCellType() == HSSFCell.CELL_TYPE_FORMULA) {
+                                       if(c.getCellType() == CellType.FORMULA) {
                                                evaluator.evaluateFormulaCell(c);
                                                
                                                // For testing - all should be numeric
-                                               assertEquals(HSSFCell.CELL_TYPE_NUMERIC, evaluator.evaluateFormulaCell(c));
+                                               assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(c));
                                        }
                                }
                        }
@@ -88,15 +90,15 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
                // Check now as expected
                assertEquals(55.7, wb.getSheetAt(0).getRow(0).getCell(2).getNumericCellValue(), 0);
                assertEquals("SUM(A1:B1)", wb.getSheetAt(0).getRow(0).getCell(2).getCellFormula());
-               assertEquals(HSSFCell.CELL_TYPE_FORMULA, wb.getSheetAt(0).getRow(0).getCell(2).getCellType());
+               assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(0).getCell(2).getCellType());
                
                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(HSSFCell.CELL_TYPE_FORMULA, wb.getSheetAt(0).getRow(1).getCell(2).getCellType());
+               assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(1).getCell(2).getCellType());
                
                assertEquals(22.3, wb.getSheetAt(1).getRow(0).getCell(0).getNumericCellValue(), 0);
                assertEquals("'S1'!A1", wb.getSheetAt(1).getRow(0).getCell(0).getCellFormula());
-               assertEquals(HSSFCell.CELL_TYPE_FORMULA, wb.getSheetAt(1).getRow(0).getCell(0).getCellType());
+               assertEquals(CellType.FORMULA, wb.getSheetAt(1).getRow(0).getCell(0).getCellType());
                
                
                // Now do the alternate call, which zaps the formulas
@@ -110,7 +112,7 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
 
                                for(Iterator cit = r.cellIterator(); cit.hasNext();) {
                                        HSSFCell c = (HSSFCell)cit.next();
-                                       if(c.getCellType() == HSSFCell.CELL_TYPE_FORMULA) {
+                                       if(c.getCellType() == CellType.FORMULA) {
                                                evaluator.evaluateInCell(c);
                                        }
                                }
@@ -118,12 +120,12 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
                }
                
                assertEquals(55.7, wb.getSheetAt(0).getRow(0).getCell(2).getNumericCellValue(), 0);
-               assertEquals(HSSFCell.CELL_TYPE_NUMERIC, wb.getSheetAt(0).getRow(0).getCell(2).getCellType());
+               assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(0).getCell(2).getCellType());
                
                assertEquals(-4.6, wb.getSheetAt(0).getRow(1).getCell(2).getNumericCellValue(), 0);
-               assertEquals(HSSFCell.CELL_TYPE_NUMERIC, wb.getSheetAt(0).getRow(1).getCell(2).getCellType());
+               assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(1).getCell(2).getCellType());
                
                assertEquals(22.3, wb.getSheetAt(1).getRow(0).getCell(0).getNumericCellValue(), 0);
-               assertEquals(HSSFCell.CELL_TYPE_NUMERIC, wb.getSheetAt(1).getRow(0).getCell(0).getCellType());
+               assertEquals(CellType.NUMERIC, wb.getSheetAt(1).getRow(0).getCell(0).getCellType());
        }
 }
index 7dfd8f3911ab97d4738e6ee069420f7a40826ae6..69842b4d4d7e3a02370d723f05e6d00d668c78fe 100644 (file)
@@ -31,6 +31,7 @@ import java.util.TimeZone;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.DateUtil;
 import org.apache.poi.util.LocaleUtil;
 import org.junit.AfterClass;
@@ -216,7 +217,7 @@ public final class TestHSSFDataFormatter {
         { // formula cell
             row = sheet.createRow(7);
             HSSFCell cell = row.createCell(0);
-            cell.setCellType(HSSFCell.CELL_TYPE_FORMULA);
+            cell.setCellType(CellType.FORMULA);
             cell.setCellFormula("SUM(12.25,12.25)/100");
             HSSFCellStyle cellStyle = wb.createCellStyle();
             cellStyle.setDataFormat(format.getFormat("##.00%;"));
@@ -383,7 +384,7 @@ public final class TestHSSFDataFormatter {
         HSSFRow row = sheet.getRow(0);
         HSSFCell cellA1 = row.getCell(0);
 
-        assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cellA1.getCellType());
+        assertEquals(CellType.NUMERIC, cellA1.getCellType());
         assertEquals(2345.0, cellA1.getNumericCellValue(), 0.0001);
         assertEquals("@", cellA1.getCellStyle().getDataFormatString());
 
index 8258bfb9ffb4a3d8896fc3fb12ef37defc9d614c..4b1e0677e0b8fe0a1a208684ab88acb9863122aa 100644 (file)
@@ -33,6 +33,7 @@ import org.apache.poi.ss.formula.eval.NumberEval;
 import org.apache.poi.ss.formula.eval.ValueEval;
 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.junit.Test;
@@ -54,7 +55,7 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
                HSSFCell cell = sheet.getRow(8).getCell(0);
                HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
                CellValue cv = fe.evaluate(cell);
-               assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType());
+               assertEquals(CellType.NUMERIC, cv.getCellType());
                assertEquals(3.72, cv.getNumberValue(), 0.0);
                wb.close();
        }
@@ -126,7 +127,7 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
                try {
                        value = hsf.evaluate(cellA1);
 
-               assertEquals(Cell.CELL_TYPE_NUMERIC, value.getCellType());
+               assertEquals(CellType.NUMERIC, value.getCellType());
                assertEquals(5.33, value.getNumberValue(), 0.0);
                
                } catch (RuntimeException e) {
@@ -198,8 +199,8 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
       
       // VLookup on a name in another file
       cell = wb1.getSheetAt(0).getRow(1).getCell(2);
-      assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
-      assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
+      assertEquals(CellType.FORMULA, cell.getCellType());
+      assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
       assertEquals(12.30, cell.getNumericCellValue(), 0.0001);
       // WARNING - this is wrong!
       // The file name should be showing, but bug #45970 is fixed
@@ -209,8 +210,8 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
       
       // Simple reference to a name in another file
       cell = wb1.getSheetAt(0).getRow(1).getCell(4);
-      assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
-      assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
+      assertEquals(CellType.FORMULA, cell.getCellType());
+      assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
       assertEquals(36.90, cell.getNumericCellValue(), 0.0001);
       // TODO Correct this!
       // The file name should be shown too, see bug #56742
@@ -236,14 +237,14 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
 
       // Re-check VLOOKUP one
       cell = wb1.getSheetAt(0).getRow(1).getCell(2);
-      assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
-      assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
+      assertEquals(CellType.FORMULA, cell.getCellType());
+      assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
       assertEquals(12.30, cell.getNumericCellValue(), 0.0001);
       
       // Re-check ref one
       cell = wb1.getSheetAt(0).getRow(1).getCell(4);
-      assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
-      assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
+      assertEquals(CellType.FORMULA, cell.getCellType());
+      assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
       assertEquals(36.90, cell.getNumericCellValue(), 0.0001);
       
       
index 6f4ed58ee2d7c15c8ef87d4c442b508b40297ab2..5d19c633f43bb8017122341610753a77c3f36a2a 100644 (file)
@@ -157,16 +157,16 @@ public class TestCellFormat {
         
         CellFormat cf = CellFormat.getInstance("General");
         
-        // case Cell.CELL_TYPE_BLANK
+        // case CellType.BLANK
         CellFormatResult result0 = cf.apply(cell0);
         assertEquals("", result0.text);
         
-        // case Cell.CELL_TYPE_BOOLEAN
+        // case CellType.BOOLEAN
         cell1.setCellValue(true);
         CellFormatResult result1 = cf.apply(cell1);
         assertEquals("TRUE", result1.text);
         
-        // case Cell.CELL_TYPE_NUMERIC
+        // case CellType.NUMERIC
         cell2.setCellValue(1.23);
         CellFormatResult result2 = cf.apply(cell2);
         assertEquals("1.23", result2.text);
@@ -175,7 +175,7 @@ public class TestCellFormat {
         CellFormatResult result3 = cf.apply(cell3);
         assertEquals("123", result3.text);
         
-        // case Cell.CELL_TYPE_STRING
+        // case CellType.STRING
         cell4.setCellValue("abc");
         CellFormatResult result4 = cf.apply(cell4);
         assertEquals("abc", result4.text);
@@ -198,16 +198,16 @@ public class TestCellFormat {
         
         CellFormat cf = CellFormat.getInstance("@");
         
-        // case Cell.CELL_TYPE_BLANK
+        // case CellType.BLANK
         CellFormatResult result0 = cf.apply(cell0);
         assertEquals("", result0.text);
         
-        // case Cell.CELL_TYPE_BOOLEAN
+        // case CellType.BOOLEAN
         cell1.setCellValue(true);
         CellFormatResult result1 = cf.apply(cell1);
         assertEquals("TRUE", result1.text);
         
-        // case Cell.CELL_TYPE_NUMERIC
+        // case CellType.NUMERIC
         cell2.setCellValue(1.23);
         CellFormatResult result2 = cf.apply(cell2);
         assertEquals("1.23", result2.text);
@@ -216,7 +216,7 @@ public class TestCellFormat {
         CellFormatResult result3 = cf.apply(cell3);
         assertEquals("123", result3.text);
         
-        // case Cell.CELL_TYPE_STRING
+        // case CellType.STRING
         cell4.setCellValue("abc");
         CellFormatResult result4 = cf.apply(cell4);
         assertEquals("abc", result4.text);
@@ -309,18 +309,18 @@ public class TestCellFormat {
         JLabel label3 = new JLabel();
         JLabel label4 = new JLabel();
         
-        // case Cell.CELL_TYPE_BLANK
+        // case CellType.BLANK
         CellFormatResult result0 = cf.apply(label0, cell0);
         assertEquals("", result0.text);
         assertEquals("", label0.getText());
         
-        // case Cell.CELL_TYPE_BOOLEAN
+        // case CellType.BOOLEAN
         cell1.setCellValue(true);
         CellFormatResult result1 = cf.apply(label1, cell1);
         assertEquals("TRUE", result1.text);
         assertEquals("TRUE", label1.getText());
         
-        // case Cell.CELL_TYPE_NUMERIC
+        // case CellType.NUMERIC
         cell2.setCellValue(1.23);
         CellFormatResult result2 = cf.apply(label2, cell2);
         assertEquals("1.23", result2.text);
@@ -331,7 +331,7 @@ public class TestCellFormat {
         assertEquals("123", result3.text);
         assertEquals("123", label3.getText());
         
-        // case Cell.CELL_TYPE_STRING
+        // case CellType.STRING
         cell4.setCellValue("abc");
         CellFormatResult result4 = cf.apply(label4, cell4);
         assertEquals("abc", result4.text);
@@ -361,18 +361,18 @@ public class TestCellFormat {
         JLabel label3 = new JLabel();
         JLabel label4 = new JLabel();
         
-        // case Cell.CELL_TYPE_BLANK
+        // case CellType.BLANK
         CellFormatResult result0 = cf.apply(label0, cell0);
         assertEquals("", result0.text);
         assertEquals("", label0.getText());
         
-        // case Cell.CELL_TYPE_BOOLEAN
+        // case CellType.BOOLEAN
         cell1.setCellValue(true);
         CellFormatResult result1 = cf.apply(label1, cell1);
         assertEquals("TRUE", result1.text);
         assertEquals("TRUE", label1.getText());
         
-        // case Cell.CELL_TYPE_NUMERIC
+        // case CellType.NUMERIC
         cell2.setCellValue(1.23);
         CellFormatResult result2 = cf.apply(label2, cell2);
         assertEquals("1.23", result2.text);
@@ -383,7 +383,7 @@ public class TestCellFormat {
         assertEquals("123", result3.text);
         assertEquals("123", label3.getText());
         
-        // case Cell.CELL_TYPE_STRING
+        // case CellType.STRING
         cell4.setCellValue("abc");
         CellFormatResult result4 = cf.apply(label4, cell4);
         assertEquals("abc", result4.text);
index 0043187c05cfe34836d7eb05b9613959c4c01ba3..d2b6577345df61f21b61bf24673aaf4bcdb3a1a9 100644 (file)
@@ -16,7 +16,9 @@
 ==================================================================== */
 package org.apache.poi.ss.formula;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.IOException;
 
@@ -30,6 +32,7 @@ import org.apache.poi.ss.formula.functions.FreeRefFunction;
 import org.apache.poi.ss.formula.udf.DefaultUDFFinder;
 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.FormulaEvaluator;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -146,12 +149,12 @@ public abstract class BaseTestExternalFunctions {
         Cell cell2 = sh.getRow(2).getCell(1);
         assertEquals("ISODD(2)", cell2.getCellFormula());
         assertEquals(false, evaluator.evaluate(cell2).getBooleanValue());
-        assertEquals(Cell.CELL_TYPE_BOOLEAN, evaluator.evaluateFormulaCell(cell2));
+        assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(cell2));
 
         Cell cell3 = sh.getRow(3).getCell(1);
         assertEquals("ISEVEN(2)", cell3.getCellFormula());
         assertEquals(true, evaluator.evaluate(cell3).getBooleanValue());
-        assertEquals(Cell.CELL_TYPE_BOOLEAN, evaluator.evaluateFormulaCell(cell3));
+        assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(cell3));
 
         wb.close();
     }
index 1c626dcee144fc2205c42c172f394adb94b91246..c469b5cdcdc1c5fce91135e45171223b3bef9c1f 100644 (file)
@@ -224,14 +224,14 @@ public class TestEvaluationCache extends TestCase {
                public void setCellValue(String cellRefText, double value) {
                        HSSFCell cell = getOrCreateCell(cellRefText);
                        // be sure to blank cell, in case it is currently a formula
-                       cell.setCellType(HSSFCell.CELL_TYPE_BLANK);
+                       cell.setCellType(CellType.BLANK);
                        // otherwise this line will only set the formula cached result;
                        cell.setCellValue(value);
                        _evaluator.notifyUpdateCell(wrapCell(cell));
                }
                public void clearCell(String cellRefText) {
                        HSSFCell cell = getOrCreateCell(cellRefText);
-                       cell.setCellType(HSSFCell.CELL_TYPE_BLANK);
+                       cell.setCellType(CellType.BLANK);
                        _evaluator.notifyUpdateCell(wrapCell(cell));
                }
 
@@ -598,7 +598,7 @@ public class TestEvaluationCache extends TestCase {
                cv = fe.evaluate(cellA1);
                assertEquals(3.7, cv.getNumberValue(), 0.0);
 
-               cellB1.setCellType(HSSFCell.CELL_TYPE_BLANK);
+               cellB1.setCellType(CellType.BLANK);
                fe.notifyUpdateCell(cellB1);
                cv = fe.evaluate(cellA1); // B1 was used to evaluate A1
                assertEquals(2.2, cv.getNumberValue(), 0.0);
index 35bb050b1ae198acee30a7a839eb55485abccde6..004097c822811e39da8b27787b64f993fbcba6d8 100644 (file)
@@ -27,6 +27,7 @@ import junit.framework.TestCase;
 \r
 import org.apache.poi.hssf.HSSFTestDataSamples;\r
 import org.apache.poi.ss.usermodel.Cell;\r
+import org.apache.poi.ss.usermodel.CellType;\r
 import org.apache.poi.ss.usermodel.FormulaEvaluator;\r
 import org.apache.poi.ss.usermodel.Row;\r
 import org.apache.poi.ss.usermodel.Sheet;\r
@@ -66,7 +67,7 @@ public class TestMissingWorkbook extends TestCase {
                Row lARow = lSheet.getRow(0);\r
                Cell lA1Cell = lARow.getCell(0);\r
                \r
-               assertEquals(Cell.CELL_TYPE_FORMULA, lA1Cell.getCellType());\r
+               assertEquals(CellType.FORMULA, lA1Cell.getCellType());\r
                try {\r
                        evaluator.evaluateFormulaCell(lA1Cell);\r
                        fail("Missing external workbook reference exception expected!");\r
@@ -81,9 +82,9 @@ public class TestMissingWorkbook extends TestCase {
                Cell lB1Cell = lSheet.getRow(1).getCell(0);\r
                Cell lC1Cell = lSheet.getRow(2).getCell(0);\r
                \r
-               assertEquals(Cell.CELL_TYPE_FORMULA, lA1Cell.getCellType());\r
-               assertEquals(Cell.CELL_TYPE_FORMULA, lB1Cell.getCellType());\r
-               assertEquals(Cell.CELL_TYPE_FORMULA, lC1Cell.getCellType());\r
+               assertEquals(CellType.FORMULA, lA1Cell.getCellType());\r
+               assertEquals(CellType.FORMULA, lB1Cell.getCellType());\r
+               assertEquals(CellType.FORMULA, lC1Cell.getCellType());\r
 \r
                // Check cached values\r
         assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d);\r
@@ -94,9 +95,9 @@ public class TestMissingWorkbook extends TestCase {
                FormulaEvaluator evaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator();\r
         evaluator.setIgnoreMissingWorkbooks(true);\r
 \r
-               assertEquals(Cell.CELL_TYPE_NUMERIC, evaluator.evaluateFormulaCell(lA1Cell));\r
-               assertEquals(Cell.CELL_TYPE_STRING,  evaluator.evaluateFormulaCell(lB1Cell));\r
-               assertEquals(Cell.CELL_TYPE_BOOLEAN, evaluator.evaluateFormulaCell(lC1Cell));\r
+               assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(lA1Cell));\r
+               assertEquals(CellType.STRING,  evaluator.evaluateFormulaCell(lB1Cell));\r
+               assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(lC1Cell));\r
 \r
                assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d);\r
                assertEquals("POI rocks!", lB1Cell.getStringCellValue());\r
@@ -110,9 +111,9 @@ public class TestMissingWorkbook extends TestCase {
                Cell lB1Cell = lSheet.getRow(1).getCell(0);\r
                Cell lC1Cell = lSheet.getRow(2).getCell(0);\r
                \r
-               assertEquals(Cell.CELL_TYPE_FORMULA, lA1Cell.getCellType());\r
-               assertEquals(Cell.CELL_TYPE_FORMULA, lB1Cell.getCellType());\r
-               assertEquals(Cell.CELL_TYPE_FORMULA, lC1Cell.getCellType());\r
+               assertEquals(CellType.FORMULA, lA1Cell.getCellType());\r
+               assertEquals(CellType.FORMULA, lB1Cell.getCellType());\r
+               assertEquals(CellType.FORMULA, lC1Cell.getCellType());\r
 \r
                FormulaEvaluator lMainWorkbookEvaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator();\r
                FormulaEvaluator lSourceEvaluator = sourceWorkbook.getCreationHelper().createFormulaEvaluator();\r
@@ -121,9 +122,9 @@ public class TestMissingWorkbook extends TestCase {
                workbooks.put(SOURCE_DUMMY_WORKBOOK_FILENAME, lSourceEvaluator);\r
                lMainWorkbookEvaluator.setupReferencedWorkbooks(workbooks);\r
                \r
-               assertEquals(Cell.CELL_TYPE_NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCell(lA1Cell));\r
-               assertEquals(Cell.CELL_TYPE_STRING, lMainWorkbookEvaluator.evaluateFormulaCell(lB1Cell));\r
-               assertEquals(Cell.CELL_TYPE_BOOLEAN, lMainWorkbookEvaluator.evaluateFormulaCell(lC1Cell));\r
+               assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCell(lA1Cell));\r
+               assertEquals(CellType.STRING, lMainWorkbookEvaluator.evaluateFormulaCell(lB1Cell));\r
+               assertEquals(CellType.BOOLEAN, lMainWorkbookEvaluator.evaluateFormulaCell(lC1Cell));\r
 \r
                assertEquals(20.0d, lA1Cell.getNumericCellValue(), 0.00001d);\r
                assertEquals("Apache rocks!", lB1Cell.getStringCellValue());\r
index 7a70fee262f328097677c946c3ddae265ec89b74..1d956c76fa9dc13143a7a47a9e160f98c4f19d46 100644 (file)
 ==================================================================== */
 package org.apache.poi.ss.formula.atp;
 
-import junit.framework.TestCase;
-
 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.FormulaEvaluator;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.ss.util.CellReference;
 
+import junit.framework.TestCase;
+
 /**
  * Testcase for 'Analysis Toolpak' function IFERROR()
  * 
@@ -45,11 +46,11 @@ public class TestIfError extends TestCase {
         Row row2 = sh.createRow(1);
 
         // Create cells
-        row1.createCell(0, Cell.CELL_TYPE_NUMERIC);
-        row1.createCell(1, Cell.CELL_TYPE_NUMERIC);
-        row1.createCell(2, Cell.CELL_TYPE_NUMERIC);
-        row2.createCell(0, Cell.CELL_TYPE_NUMERIC);
-        row2.createCell(1, Cell.CELL_TYPE_NUMERIC);
+        row1.createCell(0, CellType.NUMERIC);
+        row1.createCell(1, CellType.NUMERIC);
+        row1.createCell(2, CellType.NUMERIC);
+        row2.createCell(0, CellType.NUMERIC);
+        row2.createCell(1, CellType.NUMERIC);
 
         // Create references
         CellReference a1 = new CellReference("A1");
@@ -77,18 +78,18 @@ public class TestIfError extends TestCase {
         FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
 
         assertEquals("Checks that the cell is numeric",
-                       Cell.CELL_TYPE_NUMERIC, evaluator.evaluate(cell1).getCellType());
+                       CellType.NUMERIC, evaluator.evaluate(cell1).getCellType());
         assertEquals("Divides 210 by 35 and returns 6.0",
                 6.0, evaluator.evaluate(cell1).getNumberValue(), accuracy);
         
         
         assertEquals("Checks that the cell is numeric",
-                       Cell.CELL_TYPE_STRING, evaluator.evaluate(cell2).getCellType());        
+                       CellType.STRING, evaluator.evaluate(cell2).getCellType());        
         assertEquals("Rounds -10 to a nearest multiple of -3 (-9)",
                 "Error in calculation", evaluator.evaluate(cell2).getStringValue());
         
         assertEquals("Check that C1 returns string", 
-                       Cell.CELL_TYPE_STRING, evaluator.evaluate(cell3).getCellType());
+                       CellType.STRING, evaluator.evaluate(cell3).getCellType());
         assertEquals("Check that C1 returns string \"error\"", 
                        "error", evaluator.evaluate(cell3).getStringValue());
     }
index 6b8d50322ed3a28fe6cef164edb9d88367aab4b1..802b7d8b33176c3498aa451b506c74864bb88316 100644 (file)
@@ -21,6 +21,7 @@ import junit.framework.TestCase;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.ss.formula.eval.ErrorEval;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.FormulaEvaluator;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -49,7 +50,7 @@ public class TestRandBetween extends TestCase {
                Row row = sheet.createRow(0);
                bottomValueCell = row.createCell(0);
                topValueCell = row.createCell(1);
-               formulaCell = row.createCell(2, Cell.CELL_TYPE_FORMULA);
+               formulaCell = row.createCell(2, CellType.FORMULA);
        }
        
        @Override
@@ -113,7 +114,7 @@ public class TestRandBetween extends TestCase {
        public void testRandBetweenTopBlank() {
 
                bottomValueCell.setCellValue(-1);               
-               topValueCell.setCellType(Cell.CELL_TYPE_BLANK);
+               topValueCell.setCellType(CellType.BLANK);
                formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
                evaluator.clearAllCachedResultValues();
                evaluator.evaluateFormulaCell(formulaCell);
@@ -130,7 +131,7 @@ public class TestRandBetween extends TestCase {
                formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
                evaluator.clearAllCachedResultValues();
                evaluator.evaluateFormulaCell(formulaCell);
-               assertEquals(Cell.CELL_TYPE_ERROR, formulaCell.getCachedFormulaResultType());
+               assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
                assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
                
                
@@ -140,7 +141,7 @@ public class TestRandBetween extends TestCase {
                formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
                evaluator.clearAllCachedResultValues();
                evaluator.evaluateFormulaCell(formulaCell);
-               assertEquals(Cell.CELL_TYPE_ERROR, formulaCell.getCachedFormulaResultType());
+               assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
                assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
 
                // Check case where both inputs are of wrong type
@@ -149,7 +150,7 @@ public class TestRandBetween extends TestCase {
                formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
                evaluator.clearAllCachedResultValues();
                evaluator.evaluateFormulaCell(formulaCell);
-               assertEquals(Cell.CELL_TYPE_ERROR, formulaCell.getCachedFormulaResultType());
+               assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
                assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
        
        }
@@ -165,14 +166,14 @@ public class TestRandBetween extends TestCase {
                formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
                evaluator.clearAllCachedResultValues();
                evaluator.evaluateFormulaCell(formulaCell);
-               assertEquals(Cell.CELL_TYPE_ERROR, formulaCell.getCachedFormulaResultType());
+               assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
                assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());              
                bottomValueCell.setCellValue(1);                
-               topValueCell.setCellType(Cell.CELL_TYPE_BLANK);
+               topValueCell.setCellType(CellType.BLANK);
                formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
                evaluator.clearAllCachedResultValues();
                evaluator.evaluateFormulaCell(formulaCell);
-               assertEquals(Cell.CELL_TYPE_ERROR, formulaCell.getCachedFormulaResultType());
+               assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
                assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
        }
        
index 4860d6b05ebaf975f7bc76bd7b8c8f78fa6e429f..f52d0728e6bf4fb4815d3ea59ccbb29ff5962d9f 100644 (file)
@@ -32,6 +32,7 @@ import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.formula.eval.EvaluationException;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.util.LocaleUtil;
 import org.junit.Test;
@@ -62,7 +63,7 @@ public final class TestYearFracCalculatorFromSpreadsheet {
                        HSSFRow row = (HSSFRow) rowIterator.next();
                        
                        HSSFCell cell = row.getCell(SS.YEARFRAC_FORMULA_COLUMN);
-                       if (cell == null || cell.getCellType() != HSSFCell.CELL_TYPE_FORMULA) {
+                       if (cell == null || cell.getCellType() != CellType.FORMULA) {
                                continue;
                        }
             processRow(row, cell, formulaEvaluator);
index e82fcf75177596f78366f1e4b8348ed06b9a3a4f..4c0223afd7f05c0562b3197c13f62e544a045c94 100644 (file)
@@ -24,6 +24,7 @@ import java.io.IOException;
 
 import org.apache.poi.ss.ITestDataProvider;
 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.Row;
@@ -65,7 +66,7 @@ public abstract class BaseTestCircularReferences {
      * Makes sure that the specified evaluated cell value represents a circular reference error.
      */
     private static void confirmCycleErrorCode(CellValue cellValue) {
-        assertTrue(cellValue.getCellType() == Cell.CELL_TYPE_ERROR);
+        assertTrue(cellValue.getCellType() == CellType.ERROR);
         assertEquals(ErrorEval.CIRCULAR_REF_ERROR.getErrorCode(), cellValue.getErrorValue());
     }
 
@@ -95,7 +96,7 @@ public abstract class BaseTestCircularReferences {
 
         CellValue cellValue = evaluateWithCycles(wb, testCell);
 
-        assertTrue(cellValue.getCellType() == Cell.CELL_TYPE_NUMERIC);
+        assertTrue(cellValue.getCellType() == CellType.NUMERIC);
         assertEquals(2, cellValue.getNumberValue(), 0);
         wb.close();
     }
@@ -165,10 +166,10 @@ public abstract class BaseTestCircularReferences {
 
         // Happy day flow - evaluate A1 first
         cv = fe.evaluate(cellA1);
-        assertEquals(Cell.CELL_TYPE_NUMERIC, cv.getCellType());
+        assertEquals(CellType.NUMERIC, cv.getCellType());
         assertEquals(42.0, cv.getNumberValue(), 0.0);
         cv = fe.evaluate(cellB1); // no circ-ref-error because A1 result is cached
-        assertEquals(Cell.CELL_TYPE_NUMERIC, cv.getCellType());
+        assertEquals(CellType.NUMERIC, cv.getCellType());
         assertEquals(46.0, cv.getNumberValue(), 0.0);
 
         // Show the bug - evaluate another cell from the loop first
@@ -176,13 +177,13 @@ public abstract class BaseTestCircularReferences {
         cv = fe.evaluate(cellB1);
         // Identified bug 46898
         assertNotEquals(cv.getCellType(), ErrorEval.CIRCULAR_REF_ERROR.getErrorCode());
-        assertEquals(Cell.CELL_TYPE_NUMERIC, cv.getCellType());
+        assertEquals(CellType.NUMERIC, cv.getCellType());
         assertEquals(46.0, cv.getNumberValue(), 0.0);
 
         // start evaluation on another cell
         fe.clearAllCachedResultValues();
         cv = fe.evaluate(cellE1);
-        assertEquals(Cell.CELL_TYPE_NUMERIC, cv.getCellType());
+        assertEquals(CellType.NUMERIC, cv.getCellType());
         assertEquals(43.0, cv.getNumberValue(), 0.0);
         
         wb.close();
index 451b84071369df6ff580a622f5fc39a39116f594..561ce4bfda4972eaf217f0c2768ec0fc97b0442b 100644 (file)
@@ -58,7 +58,7 @@ public final class TestFormulaBugs {
                FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
                CellValue cv = fe.evaluate(cell);
 
-               assertEquals(Cell.CELL_TYPE_NUMERIC, cv.getCellType());
+               assertEquals(CellType.NUMERIC, cv.getCellType());
                assertEquals(3.0, cv.getNumberValue(), 0.0);
                
                wb.close();
@@ -106,11 +106,11 @@ public final class TestFormulaBugs {
                FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
                CellValue cv;
                cv = fe.evaluate(cell);
-               assertEquals(Cell.CELL_TYPE_NUMERIC, cv.getCellType());
+               assertEquals(CellType.NUMERIC, cv.getCellType());
                assertEquals(1.0, cv.getNumberValue(), 0.0);
                
                cv = fe.evaluate(row.getCell(1));
-               assertEquals(Cell.CELL_TYPE_BOOLEAN, cv.getCellType());
+               assertEquals(CellType.BOOLEAN, cv.getCellType());
                assertEquals(true, cv.getBooleanValue());
                
                wb.close();
@@ -161,7 +161,7 @@ public final class TestFormulaBugs {
                FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
                CellValue cv = fe.evaluate(cell);
 
-               assertEquals(Cell.CELL_TYPE_NUMERIC, cv.getCellType());
+               assertEquals(CellType.NUMERIC, cv.getCellType());
                assertEquals(expectedResult, cv.getNumberValue(), 0.0);
 
                wb.close();
index faeee6af3ea51c4118b42773b3fd9ab82bb468b5..c3a5eec233ceb8f14aceef028302d92f5727fdb5 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
 import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
 
 /**
@@ -77,7 +78,7 @@ public final class TestPercentEval extends TestCase {
                        // else some other unexpected error
                        throw e;
                }
-               assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType());
+               assertEquals(CellType.NUMERIC, cv.getCellType());
                assertEquals(0.5, cv.getNumberValue(), 0.0);
        }
 }
index 94a5c86e92413669cf02b3a4076c4c9f739728b5..af0d7fbde02c41b60dbf09b0b943b16207da4c5a 100644 (file)
@@ -29,11 +29,11 @@ public class CountifsTests extends TestCase {
         HSSFWorkbook workbook = new HSSFWorkbook();
         Sheet sheet = workbook.createSheet("test");
         Row row1 = sheet.createRow(0);
-        Cell cellA1 = row1.createCell(0, Cell.CELL_TYPE_FORMULA);
-        Cell cellB1 = row1.createCell(1, Cell.CELL_TYPE_NUMERIC);
-        Cell cellC1 = row1.createCell(2, Cell.CELL_TYPE_NUMERIC);
-        Cell cellD1 = row1.createCell(3, Cell.CELL_TYPE_NUMERIC);
-        Cell cellE1 = row1.createCell(4, Cell.CELL_TYPE_NUMERIC);
+        Cell cellA1 = row1.createCell(0, CellType.FORMULA);
+        Cell cellB1 = row1.createCell(1, CellType.NUMERIC);
+        Cell cellC1 = row1.createCell(2, CellType.NUMERIC);
+        Cell cellD1 = row1.createCell(3, CellType.NUMERIC);
+        Cell cellE1 = row1.createCell(4, CellType.NUMERIC);
         cellB1.setCellValue(1);
         cellC1.setCellValue(1);
         cellD1.setCellValue(2);
@@ -49,7 +49,7 @@ public class CountifsTests extends TestCase {
         HSSFWorkbook workbook = new HSSFWorkbook();
         Sheet sheet = workbook.createSheet("test");
         Row row1 = sheet.createRow(0);
-        Cell cellA1 = row1.createCell(0, Cell.CELL_TYPE_FORMULA);
+        Cell cellA1 = row1.createCell(0, CellType.FORMULA);
         cellA1.setCellFormula("COUNTIFS()");
         FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
         CellValue evaluate = evaluator.evaluate(cellA1);
index 013b15806c68ac616cf0da74c4c0fa511d127a46..8f3951aa911d8e851210ba0c674216253d41bcd6 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi.ss.formula.functions;
 import org.apache.poi.hssf.usermodel.HSSFCell;\r
 import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;\r
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;\r
+import org.apache.poi.ss.usermodel.CellType;\r
 import org.apache.poi.ss.usermodel.CellValue;\r
 \r
 import junit.framework.TestCase;\r
@@ -72,7 +73,7 @@ public final class TestAddress extends TestCase {
         cell.setCellFormula(formulaText);\r
         fe.notifyUpdateCell(cell);\r
         CellValue result = fe.evaluate(cell);\r
-        assertEquals(result.getCellType(), HSSFCell.CELL_TYPE_STRING);\r
+        assertEquals(result.getCellType(), CellType.STRING);\r
         assertEquals(expectedResult, result.getStringValue());\r
     }\r
 }\r
index 636c72a427c2bbec5060eb4221441442ee7bca82..3f88237293a5e3e888a73d213938fb87d52144a2 100644 (file)
 
 package org.apache.poi.ss.formula.functions;
 
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 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 junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
 /**
  * Test for YEAR / MONTH / DAY / HOUR / MINUTE / SECOND
  */
@@ -39,7 +39,7 @@ public final class TestCalendarFieldFunction extends TestCase {
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFSheet sheet = wb.createSheet("new sheet");
         cell11 = sheet.createRow(0).createCell(0);
-        cell11.setCellType(HSSFCell.CELL_TYPE_FORMULA);
+        cell11.setCellType(CellType.FORMULA);
         evaluator = new HSSFFormulaEvaluator(wb);
     }
 
@@ -103,7 +103,7 @@ public final class TestCalendarFieldFunction extends TestCase {
         cell11.setCellFormula(formulaText);
         evaluator.clearAllCachedResultValues();
         CellValue cv = evaluator.evaluate(cell11);
-        if (cv.getCellType() != Cell.CELL_TYPE_NUMERIC) {
+        if (cv.getCellType() != CellType.NUMERIC) {
             throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
         }
         double actualValue = cv.getNumberValue();
index ad717b162e4617af23a3ca4430eff6e6c26bc934..fe6c6a6ed57501161dab9dce26dc8e734d72cb89 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.poi.ss.formula.functions;
 import org.apache.poi.hssf.usermodel.HSSFCell;\r
 import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;\r
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;\r
+import org.apache.poi.ss.usermodel.CellType;\r
 import org.apache.poi.ss.usermodel.CellValue;\r
 \r
 import junit.framework.TestCase;\r
@@ -59,7 +60,7 @@ public final class TestClean extends TestCase {
         cell.setCellFormula(formulaText);\r
         fe.notifyUpdateCell(cell);\r
         CellValue result = fe.evaluate(cell);\r
-        assertEquals(result.getCellType(), HSSFCell.CELL_TYPE_STRING);\r
+        assertEquals(result.getCellType(), CellType.STRING);\r
         assertEquals(expectedResult, result.getStringValue());\r
     }\r
 }\r
index fd3bc4b7b75df1fbfb8da8b90585a001fe4dbb03..6dff5eda3c1aaee5780d8329e403256d5f610e3a 100644 (file)
 
 package org.apache.poi.ss.formula.functions;
 
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
 import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.formula.eval.AreaEval;
 import org.apache.poi.ss.formula.eval.BlankEval;
 import org.apache.poi.ss.formula.eval.BoolEval;
@@ -30,15 +32,14 @@ import org.apache.poi.ss.formula.eval.OperandResolver;
 import org.apache.poi.ss.formula.eval.StringEval;
 import org.apache.poi.ss.formula.eval.ValueEval;
 import org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate;
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+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.util.CellReference;
 
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
 /**
  * Test cases for COUNT(), COUNTA() COUNTIF(), COUNTBLANK()
  */
@@ -504,9 +505,9 @@ public final class TestCountFuncs extends TestCase {
         for (int rowIx=7; rowIx<=12; rowIx++) {
             HSSFRow row = sheet1.getRow(rowIx-1);
             HSSFCell cellA = row.getCell(0);  // cell containing a formula with COUNTIF
-            assertEquals(HSSFCell.CELL_TYPE_FORMULA, cellA.getCellType());
+            assertEquals(CellType.FORMULA, cellA.getCellType());
             HSSFCell cellC = row.getCell(2);  // cell with a reference value
-            assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cellC.getCellType());
+            assertEquals(CellType.NUMERIC, cellC.getCellType());
 
             CellValue cv = fe.evaluate(cellA);
             double actualValue = cv.getNumberValue();
@@ -522,9 +523,9 @@ public final class TestCountFuncs extends TestCase {
         for (int rowIx=9; rowIx<=14; rowIx++) {
             HSSFRow row = sheet2.getRow(rowIx-1);
             HSSFCell cellA = row.getCell(0);  // cell containing a formula with COUNTIF
-            assertEquals(HSSFCell.CELL_TYPE_FORMULA, cellA.getCellType());
+            assertEquals(CellType.FORMULA, cellA.getCellType());
             HSSFCell cellC = row.getCell(2);  // cell with a reference value
-            assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cellC.getCellType());
+            assertEquals(CellType.NUMERIC, cellC.getCellType());
 
             CellValue cv = fe.evaluate(cellA);
             double actualValue = cv.getNumberValue();
index 64e1c455423513f7a87a1cbffac6f0a6bdbabefb..ae3d5846ae64f0c8f7974d3a693c0d1c63ba33f8 100644 (file)
@@ -25,6 +25,7 @@ import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 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;
 
 /**
@@ -39,7 +40,7 @@ public final class TestDate extends TestCase {
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFSheet sheet = wb.createSheet("new sheet");
         cell11 = sheet.createRow(0).createCell(0);
-        cell11.setCellType(HSSFCell.CELL_TYPE_FORMULA);
+        cell11.setCellType(CellType.FORMULA);
         evaluator = new HSSFFormulaEvaluator(wb);
     }
 
@@ -81,7 +82,7 @@ public final class TestDate extends TestCase {
         cell11.setCellFormula(formulaText);
         evaluator.clearAllCachedResultValues();
         CellValue cv = evaluator.evaluate(cell11);
-        if (cv.getCellType() != Cell.CELL_TYPE_NUMERIC) {
+        if (cv.getCellType() != CellType.NUMERIC) {
             throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
         }
         double actualValue = cv.getNumberValue();
index d9eb226bfcff8aedb75d397c4be453cd4d265536..0bfff626af54f21c13020047f8926308d71b9b7c 100644 (file)
@@ -24,6 +24,7 @@ import java.io.IOException;
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
 import org.apache.poi.ss.usermodel.FormulaError;
 import org.junit.Test;
@@ -65,7 +66,7 @@ public final class TestFind {
                cell.setCellFormula(formulaText);
                fe.notifyUpdateCell(cell);
                CellValue result = fe.evaluate(cell);
-               assertEquals(result.getCellType(), HSSFCell.CELL_TYPE_NUMERIC);
+               assertEquals(result.getCellType(), CellType.NUMERIC);
                assertEquals(expectedResult, result.getNumberValue(), 0.0);
        }
 
@@ -74,7 +75,7 @@ public final class TestFind {
                cell.setCellFormula(formulaText);
                fe.notifyUpdateCell(cell);
                CellValue result = fe.evaluate(cell);
-               assertEquals(result.getCellType(), HSSFCell.CELL_TYPE_ERROR);
+               assertEquals(result.getCellType(), CellType.ERROR);
                assertEquals(expectedErrorCode.getCode(), result.getErrorValue());
        }
 }
index 8624898d57919a254fbb3a37b0f390afe716bab7..e14ea3c45b26598b66d4b353556dc38c4796db16 100644 (file)
@@ -31,7 +31,7 @@ import org.apache.poi.ss.formula.eval.ErrorEval;
 import org.apache.poi.ss.formula.eval.NumberEval;
 import org.apache.poi.ss.formula.eval.StringEval;
 import org.apache.poi.ss.formula.eval.ValueEval;
-import org.apache.poi.ss.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.junit.Before;
@@ -48,7 +48,7 @@ public final class TestFixed {
         try {
             HSSFSheet sheet = wb.createSheet("new sheet");
             cell11 = sheet.createRow(0).createCell(0);
-            cell11.setCellType(HSSFCell.CELL_TYPE_FORMULA);
+            cell11.setCellType(CellType.FORMULA);
             evaluator = new HSSFFormulaEvaluator(wb);
         } finally {
             wb.close();
@@ -117,7 +117,7 @@ public final class TestFixed {
         cell11.setCellFormula(formulaText);
         evaluator.clearAllCachedResultValues();
         CellValue cv = evaluator.evaluate(cell11);
-        assertEquals("Wrong result type: " + cv.formatAsString(), Cell.CELL_TYPE_STRING, cv.getCellType());
+        assertEquals("Wrong result type: " + cv.formatAsString(), CellType.STRING, cv.getCellType());
         String actualValue = cv.getStringValue();
         assertEquals(expectedResult, actualValue);
     }
@@ -127,7 +127,7 @@ public final class TestFixed {
         evaluator.clearAllCachedResultValues();
         CellValue cv = evaluator.evaluate(cell11);
         assertTrue("Wrong result type: " + cv.formatAsString(), 
-                cv.getCellType() == Cell.CELL_TYPE_ERROR
+                cv.getCellType() == CellType.ERROR
                 && cv.getErrorValue() == FormulaError.VALUE.getCode());
     }
 }
index c2118a147d32544734beef1788e6994dc7440adf..8e93152c81eb18fa2808e8e085d5709a56a02cae 100644 (file)
@@ -28,6 +28,7 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.formula.eval.ErrorEval;
 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.junit.Test;
@@ -182,7 +183,7 @@ public final class TestIndirect {
         fe.clearAllCachedResultValues();
         cell.setCellFormula(formula);
         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);
@@ -193,7 +194,7 @@ public final class TestIndirect {
         fe.clearAllCachedResultValues();
         cell.setCellFormula(formula);
         CellValue cv = fe.evaluate(cell);
-        if (cv.getCellType() != Cell.CELL_TYPE_ERROR) {
+        if (cv.getCellType() != CellType.ERROR) {
             fail("expected error cell type but got " + cv.formatAsString());
         }
         int expCode = expectedResult.getErrorCode();
index 7606d3fefac54091ba449c737bd80cf05f829ac3..b16fe500093e181657d572307481c27e881bdfa2 100644 (file)
 
 package org.apache.poi.ss.formula.functions;
 
-import junit.framework.TestCase;
-import junit.framework.AssertionFailedError;
-import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
 
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
 /**
  * Tests for {@link Irr}
  *
@@ -122,7 +128,7 @@ public final class TestIrr extends TestCase {
     private static void assertFormulaResult(CellValue cv, HSSFCell cell){
         double actualValue = cv.getNumberValue();
         double expectedValue = cell.getNumericCellValue(); // cached formula result calculated by Excel
-        assertEquals("Invalid formula result: " + cv.toString(), HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType());
+        assertEquals("Invalid formula result: " + cv.toString(), CellType.NUMERIC, cv.getCellType());
         assertEquals(expectedValue, actualValue, 1E-4); // should agree within 0.01%
     }
 }
index 6b40f9c173d5cb96f9ae9e394aaa547f62897a85..51b80876ec0497f533f5b2378e66995f2c05be32 100644 (file)
 
 package org.apache.poi.ss.formula.functions;
 
-import junit.framework.TestCase;
-
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
 import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
+
+import junit.framework.TestCase;
 /**
  * Tests for Excel function ISBLANK()
  * 
@@ -46,13 +47,13 @@ public final class TestIsBlank extends TestCase {
         
         HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
         CellValue result = fe.evaluate(cell);
-        assertEquals(HSSFCell.CELL_TYPE_BOOLEAN, result.getCellType());
+        assertEquals(CellType.BOOLEAN, result.getCellType());
         assertEquals(true, result.getBooleanValue());
         
         cell.setCellFormula("isblank(D7:D7)");
         
         result = fe.evaluate(cell);
-        assertEquals(HSSFCell.CELL_TYPE_BOOLEAN, result.getCellType());
+        assertEquals(CellType.BOOLEAN, result.getCellType());
         assertEquals(true, result.getBooleanValue());
    }
 }
index 628df033d0a6d83ae85a0a480201d77eda96100d..52b72dfa254a8c21d3b670dd1c56ef4f738ca569 100644 (file)
@@ -19,9 +19,9 @@ package org.apache.poi.ss.formula.functions;
 \r
 import java.io.IOException;\r
 \r
-import junit.framework.TestCase;\r
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;\r
 import org.apache.poi.ss.usermodel.Cell;\r
+import org.apache.poi.ss.usermodel.CellType;\r
 import org.apache.poi.ss.usermodel.CellValue;\r
 import org.apache.poi.ss.usermodel.FormulaEvaluator;\r
 import org.apache.poi.ss.usermodel.Row;\r
@@ -29,6 +29,8 @@ import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;\r
 import org.apache.poi.ss.util.CellReference;\r
 \r
+import junit.framework.TestCase;\r
+\r
 /**\r
  * LogicalFunction unit tests.\r
  */\r
@@ -55,11 +57,11 @@ public class TestLogicalFunction extends TestCase {
         Row row2 = sh.createRow(1);\r
         row3 = sh.createRow(2);\r
 \r
-        row1.createCell(0, Cell.CELL_TYPE_NUMERIC);\r
-        row1.createCell(1, Cell.CELL_TYPE_NUMERIC);\r
+        row1.createCell(0, CellType.NUMERIC);\r
+        row1.createCell(1, CellType.NUMERIC);\r
 \r
-        row2.createCell(0, Cell.CELL_TYPE_NUMERIC);\r
-        row2.createCell(1, Cell.CELL_TYPE_NUMERIC);\r
+        row2.createCell(0, CellType.NUMERIC);\r
+        row2.createCell(1, CellType.NUMERIC);\r
 \r
         row3.createCell(0);\r
         row3.createCell(1);\r
index a934202ed1fe82a2ea96110baca28dd9d6c3a52e..0fe105c634da828f16eb26dcaccb9f4c33ecc24b 100644 (file)
@@ -17,9 +17,6 @@
 \r
 package org.apache.poi.ss.formula.functions;\r
 \r
-import junit.framework.AssertionFailedError;\r
-import junit.framework.TestCase;\r
-\r
 import org.apache.poi.hssf.HSSFTestDataSamples;\r
 import org.apache.poi.hssf.usermodel.HSSFCell;\r
 import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;\r
@@ -28,8 +25,12 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;\r
 import org.apache.poi.ss.formula.eval.ErrorEval;\r
 import org.apache.poi.ss.formula.eval.EvaluationException;\r
+import org.apache.poi.ss.usermodel.CellType;\r
 import org.apache.poi.ss.usermodel.CellValue;\r
 \r
+import junit.framework.AssertionFailedError;\r
+import junit.framework.TestCase;\r
+\r
 /**\r
  * Tests for {@link org.apache.poi.ss.formula.functions.Mirr}\r
  *\r
@@ -161,7 +162,7 @@ public final class TestMirr extends TestCase {
     private static void assertFormulaResult(CellValue cv, HSSFCell cell) {\r
         double actualValue = cv.getNumberValue();\r
         double expectedValue = cell.getNumericCellValue(); // cached formula result calculated by Excel\r
-        assertEquals("Invalid formula result: " + cv.toString(), HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType());\r
+        assertEquals("Invalid formula result: " + cv.toString(), CellType.NUMERIC, cv.getCellType());\r
         assertEquals(expectedValue, actualValue, 1E-8);\r
     }\r
 }\r
index fe3b41122fca020bd54a81e765f7aeeb2c663aff..ec5553d84c1f5d493e463c771b254c1e0a20bb3c 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.formula.eval.NumberEval;
 import org.apache.poi.ss.formula.eval.ValueEval;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.FormulaError;
 import org.junit.Test;
 
@@ -57,12 +58,12 @@ public final class TestNper {
                cell.setCellFormula("NPER(12,4500,100000,100000)");
                cell.setCellValue(15.0);
                assertEquals("NPER(12,4500,100000,100000)", cell.getCellFormula());
-               assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
+               assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
                assertEquals(15.0, cell.getNumericCellValue(), 0.0);
 
                HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
                fe.evaluateFormulaCell(cell);
-               assertEquals(HSSFCell.CELL_TYPE_ERROR, cell.getCachedFormulaResultType());
+               assertEquals(CellType.ERROR, cell.getCachedFormulaResultType());
                assertEquals(FormulaError.NUM.getCode(), cell.getErrorCellValue());
                wb.close();
        }
index 76e175d5c9c301c888e30af19c04ea1f1e9f0c60..88d7e84fff11ae442a9a5d84a3662b816c141de4 100644 (file)
 ==================================================================== */
 package org.apache.poi.ss.formula.udf;
 
-import static org.junit.Assert.assertNotNull;
-
 import org.apache.poi.ss.formula.atp.AnalysisToolPak;
-import org.apache.poi.ss.formula.functions.FreeRefFunction;
-
 import org.junit.Test;
 
 public class TestAggregatingUDFFinder extends BaseTestUDFFinder {
index 6647276097bee6661c2342e0632473a8d6c74caf..010b19d4e2a1f7760bd5ea0919be0deb62b621fb 100644 (file)
 ==================================================================== */
 package org.apache.poi.ss.formula.udf;
 
-import static org.junit.Assert.assertNotNull;
-
 import org.apache.poi.ss.formula.functions.FreeRefFunction;
-
 import org.junit.Test;
 
 public class TestDefaultUDFFinder extends BaseTestUDFFinder {
index a1c91481a5f8795bff9d8d06f2945d2114943529..9570341fd6632bcb3e3d6ba364b06dba42a535d7 100644 (file)
@@ -672,17 +672,17 @@ public abstract class BaseTestCell {
 
         Cell cell0 = row.createCell(0);
         cell0.setCellValue(Double.NaN);
-        assertEquals("Double.NaN should change cell type to CELL_TYPE_ERROR", CellType.ERROR, cell0.getCellType());
+        assertEquals("Double.NaN should change cell type to CellType#ERROR", CellType.ERROR, cell0.getCellType());
         assertEquals("Double.NaN should change cell value to #NUM!", FormulaError.NUM, forInt(cell0.getErrorCellValue()));
 
         Cell cell1 = row.createCell(1);
         cell1.setCellValue(Double.POSITIVE_INFINITY);
-        assertEquals("Double.POSITIVE_INFINITY should change cell type to CELL_TYPE_ERROR", CellType.ERROR, cell1.getCellType());
+        assertEquals("Double.POSITIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell1.getCellType());
         assertEquals("Double.POSITIVE_INFINITY should change cell value to #DIV/0!", FormulaError.DIV0, forInt(cell1.getErrorCellValue()));
 
         Cell cell2 = row.createCell(2);
         cell2.setCellValue(Double.NEGATIVE_INFINITY);
-        assertEquals("Double.NEGATIVE_INFINITY should change cell type to CELL_TYPE_ERROR", CellType.ERROR, cell2.getCellType());
+        assertEquals("Double.NEGATIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell2.getCellType());
         assertEquals("Double.NEGATIVE_INFINITY should change cell value to #DIV/0!", FormulaError.DIV0, forInt(cell2.getErrorCellValue()));
 
         Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
index 120216bd7f899c1d5b6f021e8c0abd4bf8819b12..27ac4c93a8578e136b986309c133174d1740e404 100644 (file)
@@ -252,40 +252,40 @@ public abstract class BaseTestRow {
         // 5 -> num
         row.createCell(0).setCellValue("test");
         row.createCell(1).setCellValue(3.2);
-        row.createCell(4, Cell.CELL_TYPE_BLANK);
+        row.createCell(4, CellType.BLANK);
         row.createCell(5).setCellValue(4);
 
         // First up, no policy given, uses default
-        assertEquals(Cell.CELL_TYPE_STRING,  row.getCell(0).getCellType());
-        assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1).getCellType());
+        assertEquals(CellType.STRING,  row.getCell(0).getCellType());
+        assertEquals(CellType.NUMERIC, row.getCell(1).getCellType());
         assertEquals(null, row.getCell(2));
         assertEquals(null, row.getCell(3));
-        assertEquals(Cell.CELL_TYPE_BLANK,   row.getCell(4).getCellType());
-        assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5).getCellType());
+        assertEquals(CellType.BLANK,   row.getCell(4).getCellType());
+        assertEquals(CellType.NUMERIC, row.getCell(5).getCellType());
 
         // RETURN_NULL_AND_BLANK - same as default
-        assertEquals(Cell.CELL_TYPE_STRING,  row.getCell(0, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
-        assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
+        assertEquals(CellType.STRING,  row.getCell(0, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
+        assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
         assertEquals(null, row.getCell(2, MissingCellPolicy.RETURN_NULL_AND_BLANK));
         assertEquals(null, row.getCell(3, MissingCellPolicy.RETURN_NULL_AND_BLANK));
-        assertEquals(Cell.CELL_TYPE_BLANK,   row.getCell(4, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
-        assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
+        assertEquals(CellType.BLANK,   row.getCell(4, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
+        assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType());
 
         // RETURN_BLANK_AS_NULL - nearly the same
-        assertEquals(Cell.CELL_TYPE_STRING,  row.getCell(0, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType());
-        assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType());
+        assertEquals(CellType.STRING,  row.getCell(0, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType());
+        assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType());
         assertEquals(null, row.getCell(2, MissingCellPolicy.RETURN_BLANK_AS_NULL));
         assertEquals(null, row.getCell(3, MissingCellPolicy.RETURN_BLANK_AS_NULL));
         assertEquals(null, row.getCell(4, MissingCellPolicy.RETURN_BLANK_AS_NULL));
-        assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType());
+        assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType());
 
         // CREATE_NULL_AS_BLANK - creates as needed
-        assertEquals(Cell.CELL_TYPE_STRING,  row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
-        assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
-        assertEquals(Cell.CELL_TYPE_BLANK,   row.getCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
-        assertEquals(Cell.CELL_TYPE_BLANK,   row.getCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
-        assertEquals(Cell.CELL_TYPE_BLANK,   row.getCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
-        assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
+        assertEquals(CellType.STRING,  row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
+        assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
+        assertEquals(CellType.BLANK,   row.getCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
+        assertEquals(CellType.BLANK,   row.getCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
+        assertEquals(CellType.BLANK,   row.getCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
+        assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType());
 
         // Check created ones get the right column
         assertEquals(0, row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getColumnIndex());
@@ -300,12 +300,12 @@ public abstract class BaseTestRow {
         //  that that is now used if no policy given
         workbook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL);
 
-        assertEquals(Cell.CELL_TYPE_STRING,  row.getCell(0).getCellType());
-        assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1).getCellType());
+        assertEquals(CellType.STRING,  row.getCell(0).getCellType());
+        assertEquals(CellType.NUMERIC, row.getCell(1).getCellType());
         assertEquals(null, row.getCell(2));
         assertEquals(null, row.getCell(3));
         assertEquals(null, row.getCell(4));
-        assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5).getCellType());
+        assertEquals(CellType.NUMERIC, row.getCell(5).getCellType());
         
         workbook.close();
     }
@@ -409,7 +409,7 @@ public abstract class BaseTestRow {
         assertFalse(it.hasNext());
 
         // Add another cell, specifying the cellType
-        Cell cell5 = row.createCell(2, Cell.CELL_TYPE_STRING);
+        Cell cell5 = row.createCell(2, CellType.STRING);
         it = row.cellIterator();
         assertNotNull(cell5);
         assertTrue(it.hasNext());
@@ -420,7 +420,7 @@ public abstract class BaseTestRow {
         assertTrue(cell5 == it.next());
         assertTrue(it.hasNext());
         assertTrue(cell2 == it.next());
-        assertEquals(Cell.CELL_TYPE_STRING, cell5.getCellType());
+        assertEquals(CellType.STRING, cell5.getCellType());
         wb.close();
     }
 
index 0d3611992c22ec7a933af604a435fb2e8fbce0dd..f587b640a3ae890fadd6a0730c1c974160cfea0d 100644 (file)
@@ -344,7 +344,7 @@ public abstract class BaseTestSheetAutosizeColumn {
             Sheet sheet = workbook.getSheetAt(i);
             for (Row r : sheet) {
                 for (Cell c : r) {
-                    if (c.getCellType() == Cell.CELL_TYPE_FORMULA){
+                    if (c.getCellType() == CellType.FORMULA){
                         eval.evaluateFormulaCell(c);
                     }
                 }
index b16645e8f6366b5f75334c15c9c0327abc2446ff..ac6037b42c545d6eb1f305731118e1ec8cc5400a 100644 (file)
@@ -318,7 +318,7 @@ public abstract class BaseTestSheetShiftRows {
             Row row = sheet.createRow(i);
             
             for (int j = 0; j < 10; j++) {
-                Cell cell = row.createCell(j, Cell.CELL_TYPE_STRING);
+                Cell cell = row.createCell(j, CellType.STRING);
                 cell.setCellValue(i + "x" + j);
             }
         }
index 58919167fd4226da171624011a2359bc01f7de1b..7bfc606ec3d14c56393e0a4eb83ced77ed9d0e73 100644 (file)
@@ -133,7 +133,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
 
         for(Cell acell : cells){
             assertTrue(acell.isPartOfArrayFormulaGroup());
-            assertEquals(Cell.CELL_TYPE_FORMULA, acell.getCellType());
+            assertEquals(CellType.FORMULA, acell.getCellType());
             assertEquals("SUM(A1:A3*B1:B3)", acell.getCellFormula());
             //retrieve the range and check it is the same
             assertEquals(range.formatAsString(), acell.getArrayFormulaRange().formatAsString());
@@ -210,7 +210,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
 
         for(Cell acell : cr){
             assertFalse(acell.isPartOfArrayFormulaGroup());
-            assertEquals(Cell.CELL_TYPE_BLANK, acell.getCellType());
+            assertEquals(CellType.BLANK, acell.getCellType());
         }
 
         // cells C4:C6 are not included in array formula,
@@ -279,7 +279,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
         CellRange<? extends Cell> srange =
                 sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5"));
         Cell scell = srange.getTopLeftCell();
-        assertEquals(Cell.CELL_TYPE_FORMULA, scell.getCellType());
+        assertEquals(CellType.FORMULA, scell.getCellType());
         assertEquals(0.0, scell.getNumericCellValue(), 0);
         scell.setCellValue(1.1);
         assertEquals(1.1, scell.getNumericCellValue(), 0);
@@ -288,7 +288,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
         CellRange<? extends Cell> mrange =
                 sheet.setArrayFormula("A1:A3*B1:B3", CellRangeAddress.valueOf("C1:C3"));
         for(Cell mcell : mrange){
-            assertEquals(Cell.CELL_TYPE_FORMULA, mcell.getCellType());
+            assertEquals(CellType.FORMULA, mcell.getCellType());
             assertEquals(0.0, mcell.getNumericCellValue(), 0);
             double fmlaResult = 1.2;
             mcell.setCellValue(fmlaResult);
@@ -307,10 +307,10 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
         CellRange<? extends Cell> srange =
                 sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5"));
         Cell scell = srange.getTopLeftCell();
-        assertEquals(Cell.CELL_TYPE_FORMULA, scell.getCellType());
+        assertEquals(CellType.FORMULA, scell.getCellType());
         assertEquals(0.0, scell.getNumericCellValue(), 0);
-        scell.setCellType(Cell.CELL_TYPE_STRING);
-        assertEquals(Cell.CELL_TYPE_STRING, scell.getCellType());
+        scell.setCellType(CellType.STRING);
+        assertEquals(CellType.STRING, scell.getCellType());
         scell.setCellValue("string cell");
         assertEquals("string cell", scell.getStringCellValue());
 
@@ -319,8 +319,8 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
                 sheet.setArrayFormula("A1:A3*B1:B3", CellRangeAddress.valueOf("C1:C3"));
         for(Cell mcell : mrange){
             try {
-                assertEquals(Cell.CELL_TYPE_FORMULA, mcell.getCellType());
-                mcell.setCellType(Cell.CELL_TYPE_NUMERIC);
+                assertEquals(CellType.FORMULA, mcell.getCellType());
+                mcell.setCellType(CellType.NUMERIC);
                 fail("expected exception");
             } catch (IllegalStateException e){
                 CellReference ref = new CellReference(mcell);
@@ -329,7 +329,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
             }
             // a failed invocation of Cell.setCellType leaves the cell
             // in the state that it was in prior to the invocation
-            assertEquals(Cell.CELL_TYPE_FORMULA, mcell.getCellType());
+            assertEquals(CellType.FORMULA, mcell.getCellType());
             assertTrue(mcell.isPartOfArrayFormulaGroup());
         }
         workbook.close();
@@ -344,13 +344,13 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
                 sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5"));
         Cell scell = srange.getTopLeftCell();
         assertEquals("SUM(A4:A6,B4:B6)", scell.getCellFormula());
-        assertEquals(Cell.CELL_TYPE_FORMULA, scell.getCellType());
+        assertEquals(CellType.FORMULA, scell.getCellType());
         assertTrue(scell.isPartOfArrayFormulaGroup());
         scell.setCellFormula("SUM(A4,A6)");
         //we are now a normal formula cell
         assertEquals("SUM(A4,A6)", scell.getCellFormula());
         assertFalse(scell.isPartOfArrayFormulaGroup());
-        assertEquals(Cell.CELL_TYPE_FORMULA, scell.getCellType());
+        assertEquals(CellType.FORMULA, scell.getCellType());
         //check that setting formula result works
         assertEquals(0.0, scell.getNumericCellValue(), 0);
         scell.setCellValue(33.0);
@@ -396,7 +396,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
 
         //re-create the removed cell
         scell = srow.createCell(cra.getFirstColumn());
-        assertEquals(Cell.CELL_TYPE_BLANK, scell.getCellType());
+        assertEquals(CellType.BLANK, scell.getCellType());
         assertFalse(scell.isPartOfArrayFormulaGroup());
 
         //we cannot remove cells included in a multi-cell array formula
@@ -417,7 +417,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
             // in the state that it was in prior to the invocation
             assertSame(mcell, mrow.getCell(columnIndex));
             assertTrue(mcell.isPartOfArrayFormulaGroup());
-            assertEquals(Cell.CELL_TYPE_FORMULA, mcell.getCellType());
+            assertEquals(CellType.FORMULA, mcell.getCellType());
         }
         
         workbook.close();
@@ -433,7 +433,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
         CellRange<? extends Cell> srange =
                 sheet.setArrayFormula("SUM(A4:A6,B4:B6)", cra);
         Cell scell = srange.getTopLeftCell();
-        assertEquals(Cell.CELL_TYPE_FORMULA, scell.getCellType());
+        assertEquals(CellType.FORMULA, scell.getCellType());
 
         Row srow = scell.getRow();
         assertSame(srow, sheet.getRow(cra.getFirstRow()));
@@ -442,7 +442,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
 
         //re-create the removed row and cell
         scell = sheet.createRow(cra.getFirstRow()).createCell(cra.getFirstColumn());
-        assertEquals(Cell.CELL_TYPE_BLANK, scell.getCellType());
+        assertEquals(CellType.BLANK, scell.getCellType());
         assertFalse(scell.isPartOfArrayFormulaGroup());
 
         //we cannot remove rows with cells included in a multi-cell array formula
@@ -463,7 +463,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
             assertSame(mrow, sheet.getRow(mrow.getRowNum()));
             assertSame(mcell, mrow.getCell(columnIndex));
             assertTrue(mcell.isPartOfArrayFormulaGroup());
-            assertEquals(Cell.CELL_TYPE_FORMULA, mcell.getCellType());
+            assertEquals(CellType.FORMULA, mcell.getCellType());
         }
         
         workbook.close();
@@ -481,7 +481,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
         Cell scell = srange.getTopLeftCell();
         sheet.addMergedRegion(CellRangeAddress.valueOf("B5:C6"));
         //we are still an array formula
-        assertEquals(Cell.CELL_TYPE_FORMULA, scell.getCellType());
+        assertEquals(CellType.FORMULA, scell.getCellType());
         assertTrue(scell.isPartOfArrayFormulaGroup());
         assertEquals(1, sheet.getNumMergedRegions());
         
@@ -570,7 +570,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas {
             assertEquals(cra.formatAsString(), mcell.getArrayFormulaRange().formatAsString());
             assertEquals("A2:A4*B2:B4", mcell.getCellFormula());
             assertTrue(mcell.isPartOfArrayFormulaGroup());
-            assertEquals(Cell.CELL_TYPE_FORMULA, mcell.getCellType());
+            assertEquals(CellType.FORMULA, mcell.getCellType());
         }
 
         */
index 95d173aa3e5963a1401e41bfc742493fcbd2a175..c4903214a029a0f6189dc301a6117e1631b7cf58 100644 (file)
@@ -583,7 +583,7 @@ public class TestDataFormatter {
         try {
             Sheet s = wb.createSheet();
             Row r = s.createRow(0);
-            Cell c = r.createCell(0, Cell.CELL_TYPE_ERROR);
+            Cell c = r.createCell(0, CellType.ERROR);
 
             c.setCellErrorValue(FormulaError.DIV0.getCode());
             assertEquals(FormulaError.DIV0.getString(), dfUS.formatCellValue(c));
index ee90ee6c5a490a723cd47250c41500a84a2b5e9a..7a668b016dbb5d1ea725fa3f1319319af79b734c 100644 (file)
@@ -19,13 +19,14 @@ package org.apache.poi.ss.util;
 
 import java.util.Date;
 
-import junit.framework.TestCase;
-
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Cell;
 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.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+
+import junit.framework.TestCase;
 
 /**
  * Tests SheetBuilder.
@@ -49,7 +50,7 @@ public final class TestSheetBuilder extends TestCase {
         Row firstRow = sheet.getRow(0);
         Cell firstCell = firstRow.getCell(0);
 
-        assertEquals(firstCell.getCellType(), Cell.CELL_TYPE_NUMERIC);
+        assertEquals(firstCell.getCellType(), CellType.NUMERIC);
         assertEquals(1.0, firstCell.getNumericCellValue(), 0.00001);
 
 
@@ -58,11 +59,11 @@ public final class TestSheetBuilder extends TestCase {
         assertNull(secondRow.getCell(2));
 
         Row thirdRow = sheet.getRow(2);
-        assertEquals(Cell.CELL_TYPE_STRING, thirdRow.getCell(0).getCellType());
+        assertEquals(CellType.STRING, thirdRow.getCell(0).getCellType());
         String cellValue = thirdRow.getCell(0).getStringCellValue();
         assertEquals(testData[2][0].toString(), cellValue);
 
-        assertEquals(Cell.CELL_TYPE_FORMULA, thirdRow.getCell(2).getCellType());
+        assertEquals(CellType.FORMULA, thirdRow.getCell(2).getCellType());
         assertEquals("A1+B2", thirdRow.getCell(2).getCellFormula());
     }
 
@@ -72,7 +73,7 @@ public final class TestSheetBuilder extends TestCase {
 
         Cell emptyCell = sheet.getRow(1).getCell(1);
         assertNotNull(emptyCell);
-        assertEquals(Cell.CELL_TYPE_BLANK, emptyCell.getCellType());
+        assertEquals(CellType.BLANK, emptyCell.getCellType());
     }
 
     public void testSheetName() {