From: Javen O'Neal Date: Mon, 4 Jul 2016 10:15:18 +0000 (+0000) Subject: bug 59791: replace deprecated Cell.CELL_TYPE_* usage with CellType.* X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=64ef8e26a3c23626c2033e752a96c2caf79eedc6;p=poi.git bug 59791: replace deprecated Cell.CELL_TYPE_* usage with CellType.* git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751240 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java index 07b9b0165a..3e31d11f26 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java @@ -17,15 +17,15 @@ 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"); diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java index 8ed9213bfa..148b2a58b0 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java @@ -17,11 +17,15 @@ 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"); diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java index 7653a0b527..018556f991 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java @@ -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))); diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java index 26bba44674..2b3553f768 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java @@ -17,16 +17,17 @@ 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 diff --git a/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java b/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java index caace28f7f..b33d8cba10 100644 --- a/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java +++ b/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java @@ -16,20 +16,37 @@ ==================================================================== */ 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(); diff --git a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java b/src/examples/src/org/apache/poi/ss/examples/ToCSV.java index 67b6d56a6d..616f838706 100644 --- a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java +++ b/src/examples/src/org/apache/poi/ss/examples/ToCSV.java @@ -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 { diff --git a/src/java/org/apache/poi/hssf/record/RecordInputStream.java b/src/java/org/apache/poi/hssf/record/RecordInputStream.java index 2b66bd80a3..81ec0776b3 100644 --- a/src/java/org/apache/poi/hssf/record/RecordInputStream.java +++ b/src/java/org/apache/poi/hssf/record/RecordInputStream.java @@ -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; } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java b/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java index 238b89ed39..347300d5f4 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java @@ -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(); diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java index ba4c7b58c9..f67de61271 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java @@ -99,7 +99,7 @@ public final class HSSFRow implements Row, Comparable { /** * Use this to create new cells within the row and return it. *

- * 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 setCellValue or setCellType. * * @param column - the column number this cell represents diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 037c6b7548..698e20a06e 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -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 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; } diff --git a/src/java/org/apache/poi/ss/format/CellFormat.java b/src/java/org/apache/poi/ss/format/CellFormat.java index df60021dd6..5775fd3b2e 100644 --- a/src/java/org/apache/poi/ss/format/CellFormat.java +++ b/src/java/org/apache/poi/ss/format/CellFormat.java @@ -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()}. * diff --git a/src/java/org/apache/poi/ss/formula/EvaluationCache.java b/src/java/org/apache/poi/ss/formula/EvaluationCache.java index 6b9278e3c5..ff655f36bb 100644 --- a/src/java/org/apache/poi/ss/formula/EvaluationCache.java +++ b/src/java/org/apache/poi/ss/formula/EvaluationCache.java @@ -17,16 +17,16 @@ 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 diff --git a/src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java b/src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java index bc4c862620..c9b408fa51 100644 --- a/src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java +++ b/src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java @@ -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){ diff --git a/src/java/org/apache/poi/ss/formula/eval/RefEval.java b/src/java/org/apache/poi/ss/formula/eval/RefEval.java index c8e0296fe2..46aa96c04c 100644 --- a/src/java/org/apache/poi/ss/formula/eval/RefEval.java +++ b/src/java/org/apache/poi/ss/formula/eval/RefEval.java @@ -18,13 +18,14 @@ 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 { diff --git a/src/java/org/apache/poi/ss/usermodel/Cell.java b/src/java/org/apache/poi/ss/usermodel/Cell.java index be66389543..0191b159dd 100644 --- a/src/java/org/apache/poi/ss/usermodel/Cell.java +++ b/src/java/org/apache/poi/ss/usermodel/Cell.java @@ -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); diff --git a/src/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java b/src/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java index 1f7c8fd833..b68a729a26 100644 --- a/src/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java +++ b/src/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java @@ -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); diff --git a/src/java/org/apache/poi/ss/usermodel/charts/DataSources.java b/src/java/org/apache/poi/ss/usermodel/charts/DataSources.java index 2f443814ee..3bf891e0a9 100644 --- a/src/java/org/apache/poi/ss/usermodel/charts/DataSources.java +++ b/src/java/org/apache/poi/ss/usermodel/charts/DataSources.java @@ -42,7 +42,7 @@ public class DataSources { return new AbstractCellRangeDataSource(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(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; diff --git a/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java b/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java index 667fb03c53..c72048ec26 100644 --- a/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java +++ b/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java @@ -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); } /** diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java index 3415af3010..965534f34b 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java @@ -22,6 +22,7 @@ import org.apache.poi.ss.formula.IStabilityClassifier; import org.apache.poi.ss.formula.WorkbookEvaluator; import org.apache.poi.ss.formula.udf.UDFFinder; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.util.POILogFactory; @@ -120,7 +121,7 @@ public final class SXSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator { // Evaluate what we have for (Row r : sheet) { for (Cell c : r) { - if (c.getCellType() == Cell.CELL_TYPE_FORMULA) { + if (c.getCellType() == CellType.FORMULA) { eval.evaluateFormulaCell(c); } } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java index 81359d3857..6d337f4465 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java @@ -110,7 +110,7 @@ public abstract class BaseXSSFFormulaEvaluator implements FormulaEvaluator, Work * and the result. If you want the cell replaced with * the result of the formula, use {@link #evaluate(org.apache.poi.ss.usermodel.Cell)} } * @param cell The cell to evaluate - * @return The type of the formula result (the cell's type remains as HSSFCell.CELL_TYPE_FORMULA however) + * @return The type of the formula result (the cell's type remains as CellType.FORMULA however) */ public CellType evaluateFormulaCell(Cell cell) { if (cell == null || cell.getCellType() != CellType.FORMULA) { diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java index c611e13e38..8ab465aff1 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotCacheDefinition.java @@ -29,6 +29,7 @@ import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.util.AreaReference; @@ -143,7 +144,7 @@ public class XSSFPivotCacheDefinition extends POIXMLDocumentPart{ //General number format cf.setNumFmtId(0); Cell cell = row.getCell(i); - cell.setCellType(Cell.CELL_TYPE_STRING); + cell.setCellType(CellType.STRING); cf.setName(row.getCell(i).getStringCellValue()); cf.addNewSharedItems(); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java index d0e9d1a8ce..9f68649199 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPivotTable.java @@ -31,6 +31,7 @@ import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.DataConsolidateFunction; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.util.AreaReference; @@ -39,26 +40,7 @@ import org.apache.poi.util.Beta; import org.apache.poi.util.Internal; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCacheSource; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColFields; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDataField; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDataFields; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTField; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTItems; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTLocation; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageField; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageFields; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotCacheDefinition; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotField; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotFields; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotTableDefinition; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotTableStyle; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRowFields; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheetSource; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.STAxis; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.STDataConsolidateFunction; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.STItemType; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.STSourceType; +import org.openxmlformats.schemas.spreadsheetml.x2006.main.*; public class XSSFPivotTable extends POIXMLDocumentPart { @@ -357,7 +339,7 @@ public class XSSFPivotTable extends POIXMLDocumentPart { dataField.setSubtotal(STDataConsolidateFunction.Enum.forInt(function.getValue())); Cell cell = getDataSheet().getRow(pivotArea.getFirstCell().getRow()) .getCell(pivotArea.getFirstCell().getCol() + columnIndex); - cell.setCellType(Cell.CELL_TYPE_STRING); + cell.setCellType(CellType.STRING); dataField.setName(valueFieldName); dataField.setFld(columnIndex); dataFields.setCount(dataFields.sizeOfDataFieldArray()); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 3ae3d5b579..efd45943fa 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -43,7 +43,6 @@ import javax.xml.namespace.QName; import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLException; - import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.PartAlreadyExistsException; import org.apache.poi.openxml4j.opc.PackagePart; @@ -58,6 +57,7 @@ import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellCopyPolicy; import org.apache.poi.ss.usermodel.CellRange; import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.DataValidation; import org.apache.poi.ss.usermodel.DataValidationHelper; import org.apache.poi.ss.usermodel.Footer; @@ -3782,7 +3782,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { arrayFormulas.remove(range); CellRange cr = getCellRange(range); for (XSSFCell c : cr) { - c.setCellType(Cell.CELL_TYPE_BLANK); + c.setCellType(CellType.BLANK); } return cr; } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java index 99e8a1e408..107e205b98 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java @@ -26,6 +26,7 @@ import org.apache.poi.ss.formula.ptg.Ptg; import org.apache.poi.ss.formula.ptg.Pxg; import org.apache.poi.ss.formula.ptg.Pxg3D; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.xssf.usermodel.XSSFCell; @@ -76,7 +77,7 @@ public final class XSSFFormulaUtils { for (Sheet sh : _wb) { for (Row row : sh) { for (Cell cell : row) { - if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) { + if (cell.getCellType() == CellType.FORMULA) { updateFormula((XSSFCell) cell, oldName, newName); } } diff --git a/src/ooxml/testcases/org/apache/poi/ss/formula/TestStructuredReferences.java b/src/ooxml/testcases/org/apache/poi/ss/formula/TestStructuredReferences.java index a21ad32a05..fd598a479b 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/formula/TestStructuredReferences.java +++ b/src/ooxml/testcases/org/apache/poi/ss/formula/TestStructuredReferences.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellValue; import org.apache.poi.ss.usermodel.FormulaEvaluator; import org.apache.poi.ss.usermodel.Table; @@ -72,7 +73,7 @@ public class TestStructuredReferences { private static void confirm(FormulaEvaluator fe, Cell cell, double expectedResult) { fe.clearAllCachedResultValues(); CellValue cv = fe.evaluate(cell); - if (cv.getCellType() != Cell.CELL_TYPE_NUMERIC) { + if (cv.getCellType() != CellType.NUMERIC) { fail("expected numeric cell type but got " + cv.formatAsString()); } assertEquals(expectedResult, cv.getNumberValue(), 0.0); diff --git a/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestProper.java b/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestProper.java index cac071f416..40500480a6 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestProper.java +++ b/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestProper.java @@ -23,6 +23,7 @@ import junit.framework.TestCase; import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellValue; import org.apache.poi.ss.usermodel.FormulaEvaluator; import org.apache.poi.ss.usermodel.Sheet; @@ -52,7 +53,7 @@ public final class TestProper extends TestCase { private void confirm(Workbook wb) { Sheet sheet = wb.createSheet("new sheet"); cell11 = sheet.createRow(0).createCell(0); - cell11.setCellType(XSSFCell.CELL_TYPE_FORMULA); + cell11.setCellType(CellType.FORMULA); confirm("PROPER(\"hi there\")", "Hi There"); confirm("PROPER(\"what's up\")", "What'S Up"); @@ -77,7 +78,7 @@ public final class TestProper extends TestCase { cell11.setCellFormula(formulaText); evaluator.clearAllCachedResultValues(); CellValue cv = evaluator.evaluate(cell11); - if (cv.getCellType() != Cell.CELL_TYPE_STRING) { + if (cv.getCellType() != CellType.STRING) { throw new AssertionFailedError("Wrong result type: " + cv.formatAsString()); } String actualValue = cv.getStringValue(); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java b/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java index ccc883dd30..b36b867736 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExportToXML.java @@ -32,6 +32,7 @@ import junit.framework.TestCase; import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.util.XMLHelper; @@ -513,30 +514,30 @@ public final class TestXSSFExportToXML extends TestCase { Cell cString = row.createCell(0); cString.setCellValue("somestring"); - cString.setCellType(XSSFCell.CELL_TYPE_STRING); + cString.setCellType(CellType.STRING); Cell cBoolean = row.createCell(1); cBoolean.setCellValue(true); - cBoolean.setCellType(XSSFCell.CELL_TYPE_BOOLEAN); + cBoolean.setCellType(CellType.BOOLEAN); Cell cError = row.createCell(2); - cError.setCellType(XSSFCell.CELL_TYPE_ERROR); + cError.setCellType(CellType.ERROR); Cell cFormulaString = row.createCell(3); cFormulaString.setCellFormula("A1"); - cFormulaString.setCellType(XSSFCell.CELL_TYPE_FORMULA); + cFormulaString.setCellType(CellType.FORMULA); Cell cFormulaNumeric = row.createCell(4); cFormulaNumeric.setCellFormula("F1"); - cFormulaNumeric.setCellType(XSSFCell.CELL_TYPE_FORMULA); + cFormulaNumeric.setCellType(CellType.FORMULA); Cell cNumeric = row.createCell(5); cNumeric.setCellValue(1.2); - cNumeric.setCellType(XSSFCell.CELL_TYPE_NUMERIC); + cNumeric.setCellType(CellType.NUMERIC); Cell cDate = row.createCell(6); cDate.setCellValue(new Date()); - cDate.setCellType(XSSFCell.CELL_TYPE_NUMERIC); + cDate.setCellType(CellType.NUMERIC); boolean found = false; for (POIXMLDocumentPart p : wb.getRelations()) { diff --git a/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java b/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java index 0932177e00..42cf2714a5 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java @@ -17,9 +17,12 @@ package org.apache.poi.xssf.model; -import org.apache.poi.xssf.usermodel.*; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.xssf.XSSFTestDataSamples; -import org.openxmlformats.schemas.spreadsheetml.x2006.main.*; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcCell; import junit.framework.TestCase; @@ -39,7 +42,7 @@ public final class TestCalculationChain extends TestCase { XSSFSheet sheet = wb.getSheet("Test"); XSSFCell cell = sheet.getRow(0).getCell(4); - assertEquals(XSSFCell.CELL_TYPE_FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellType()); cell.setCellFormula(null); //the count of items is less by one @@ -50,9 +53,9 @@ public final class TestCalculationChain extends TestCase { assertEquals(10, c.getI()); assertEquals("C1", c.getR()); - assertEquals(XSSFCell.CELL_TYPE_STRING, cell.getCellType()); + assertEquals(CellType.STRING, cell.getCellType()); cell.setCellValue("ABC"); - assertEquals(XSSFCell.CELL_TYPE_STRING, cell.getCellType()); + assertEquals(CellType.STRING, cell.getCellType()); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java index 4fbdbcd6e9..67ebe1ef00 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java @@ -37,6 +37,7 @@ import org.apache.poi.POITestCase; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.BaseTestXWorkbook; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; @@ -524,7 +525,7 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook { Arrays.fill(useless, 0, 10, ' '); System.arraycopy(prefix, 0, useless, 0, prefix.length); String ul = new String(useless); - r.createCell(col, Cell.CELL_TYPE_STRING).setCellValue(ul); + r.createCell(col, CellType.STRING).setCellValue(ul); ul = null; } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java index b9c5c9809a..8c6951de18 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java @@ -34,6 +34,7 @@ import org.apache.poi.ss.usermodel.BorderStyle; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellCopyPolicy; import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CreationHelper; import org.apache.poi.ss.usermodel.DataFormatter; import org.apache.poi.ss.usermodel.Font; @@ -70,7 +71,7 @@ public final class TestXSSFCell extends BaseTestXCell { Sheet sheet = wb.getSheetAt(0); Row row = sheet.getRow(0); Cell cell = row.getCell(0); - cell.setCellType(Cell.CELL_TYPE_STRING); + cell.setCellType(CellType.STRING); cell.setCellValue("456"); wb.close(); } @@ -133,13 +134,13 @@ public final class TestXSSFCell extends BaseTestXCell { assertNull(str.getString()); cell_0.setCellValue(str); assertEquals(0, sst.getCount()); - assertEquals(Cell.CELL_TYPE_BLANK, cell_0.getCellType()); + assertEquals(CellType.BLANK, cell_0.getCellType()); //case 2. cell.setCellValue((String)null); Cell cell_1 = row.createCell(1); cell_1.setCellValue((String)null); assertEquals(0, sst.getCount()); - assertEquals(Cell.CELL_TYPE_BLANK, cell_1.getCellType()); + assertEquals(CellType.BLANK, cell_1.getCellType()); wb.close(); } @@ -151,7 +152,7 @@ public final class TestXSSFCell extends BaseTestXCell { CTCell ctCell = cell.getCTCell(); //low-level bean holding cell's xml cell.setCellFormula("A2"); - assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellType()); assertEquals("A2", cell.getCellFormula()); //the value is not set and cell's type='N' which means blank assertEquals(STCellType.N, ctCell.getT()); @@ -159,7 +160,7 @@ public final class TestXSSFCell extends BaseTestXCell { //set cached formula value cell.setCellValue("t='str'"); //we are still of 'formula' type - assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellType()); assertEquals("A2", cell.getCellFormula()); //cached formula value is set and cell's type='STR' assertEquals(STCellType.STR, ctCell.getT()); @@ -167,14 +168,14 @@ public final class TestXSSFCell extends BaseTestXCell { //now remove the formula, the cached formula result remains cell.setCellFormula(null); - assertEquals(Cell.CELL_TYPE_STRING, cell.getCellType()); + assertEquals(CellType.STRING, cell.getCellType()); assertEquals(STCellType.STR, ctCell.getT()); //the line below failed prior to fix of Bug #47889 assertEquals("t='str'", cell.getStringCellValue()); //revert to a blank cell cell.setCellValue((String)null); - assertEquals(Cell.CELL_TYPE_BLANK, cell.getCellType()); + assertEquals(CellType.BLANK, cell.getCellType()); assertEquals(STCellType.N, ctCell.getT()); assertEquals("", cell.getStringCellValue()); } finally { @@ -194,7 +195,7 @@ public final class TestXSSFCell extends BaseTestXCell { //try a string cell cell = sh.getRow(0).getCell(0); - assertEquals(Cell.CELL_TYPE_STRING, cell.getCellType()); + assertEquals(CellType.STRING, cell.getCellType()); assertEquals("a", cell.getStringCellValue()); assertEquals("a", cell.toString()); //Gnumeric produces spreadsheets without styles @@ -203,7 +204,7 @@ public final class TestXSSFCell extends BaseTestXCell { //try a numeric cell cell = sh.getRow(1).getCell(0); - assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCellType()); + assertEquals(CellType.NUMERIC, cell.getCellType()); assertEquals(1.0, cell.getNumericCellValue(), 0); assertEquals("1.0", cell.toString()); //Gnumeric produces spreadsheets without styles @@ -513,7 +514,7 @@ public final class TestXSSFCell extends BaseTestXCell { final CellCopyPolicy policy = new CellCopyPolicy(); destCell.copyCellFrom(srcCell, policy); - assertEquals(Cell.CELL_TYPE_FORMULA, destCell.getCellType()); + assertEquals(CellType.FORMULA, destCell.getCellType()); assertEquals("2+3", destCell.getCellFormula()); assertEquals(srcCell.getCellStyle(), destCell.getCellStyle()); } @@ -525,7 +526,7 @@ public final class TestXSSFCell extends BaseTestXCell { // Paste values only final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellFormula(false).build(); destCell.copyCellFrom(srcCell, policy); - assertEquals(Cell.CELL_TYPE_NUMERIC, destCell.getCellType()); + assertEquals(CellType.NUMERIC, destCell.getCellType()); } @Test @@ -552,8 +553,8 @@ public final class TestXSSFCell extends BaseTestXCell { assertEquals(srcCell.getCellStyle(), destCell.getCellStyle()); // Old cell value should not have been overwritten - assertNotEquals(Cell.CELL_TYPE_BLANK, destCell.getCellType()); - assertEquals(Cell.CELL_TYPE_BOOLEAN, destCell.getCellType()); + assertNotEquals(CellType.BLANK, destCell.getCellType()); + assertEquals(CellType.BOOLEAN, destCell.getCellType()); assertEquals(true, destCell.getBooleanCellValue()); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java index 8be5121426..d9cbec5dd1 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataValidation.java @@ -24,6 +24,7 @@ import java.util.List; import org.apache.poi.ss.usermodel.BaseTestDataValidation; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.DataValidation; import org.apache.poi.ss.usermodel.DataValidationConstraint; import org.apache.poi.ss.usermodel.DataValidationConstraint.OperatorType; @@ -141,7 +142,7 @@ public class TestXSSFDataValidation extends BaseTestDataValidation { Cell cell_13 = row1.createCell(3); - cell_13.setCellType(Cell.CELL_TYPE_NUMERIC); + cell_13.setCellType(CellType.NUMERIC); cell_13.setCellValue(validationType==ValidationType.DECIMAL ? dvalue.doubleValue() : value.intValue()); @@ -204,11 +205,11 @@ public class TestXSSFDataValidation extends BaseTestDataValidation { String value1String = validationType==ValidationType.DECIMAL ? dvalue.toString() : value.toString(); - cell_13.setCellType(Cell.CELL_TYPE_NUMERIC); + cell_13.setCellType(CellType.NUMERIC); cell_13.setCellValue(validationType==ValidationType.DECIMAL ? dvalue.doubleValue() : value.intValue()); String value2String = validationType==ValidationType.DECIMAL ? dvalue2.toString() : value2.toString(); - cell_14.setCellType(Cell.CELL_TYPE_NUMERIC); + cell_14.setCellType(CellType.NUMERIC); cell_14.setCellValue(validationType==ValidationType.DECIMAL ? dvalue2.doubleValue() : value2.intValue()); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java index 87475771bd..28cc7f79a3 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java @@ -26,6 +26,7 @@ import java.util.Map; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.ss.usermodel.BaseTestFormulaEvaluator; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellValue; import org.apache.poi.ss.usermodel.FormulaError; import org.apache.poi.ss.usermodel.FormulaEvaluator; @@ -369,32 +370,32 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { // sheet1 A1 XSSFCell cell = sheet1.createRow(0).createCell(0); - cell.setCellType(Cell.CELL_TYPE_NUMERIC); + cell.setCellType(CellType.NUMERIC); cell.setCellValue(1.0); // sheet2 A1 cell = sheet2.createRow(0).createCell(0); - cell.setCellType(Cell.CELL_TYPE_NUMERIC); + cell.setCellType(CellType.NUMERIC); cell.setCellValue(1.0); // sheet2 B1 cell = sheet2.getRow(0).createCell(1); - cell.setCellType(Cell.CELL_TYPE_NUMERIC); + cell.setCellType(CellType.NUMERIC); cell.setCellValue(1.0); // sheet3 A1 cell = sheet3.createRow(0).createCell(0); - cell.setCellType(Cell.CELL_TYPE_NUMERIC); + cell.setCellType(CellType.NUMERIC); cell.setCellValue(1.0); // sheet1 A2 formulae cell = sheet1.createRow(1).createCell(0); - cell.setCellType(Cell.CELL_TYPE_FORMULA); + cell.setCellType(CellType.FORMULA); cell.setCellFormula("SUM(Sheet1:Sheet3!A1)"); // sheet1 A3 formulae cell = sheet1.createRow(2).createCell(0); - cell.setCellType(Cell.CELL_TYPE_FORMULA); + cell.setCellType(CellType.FORMULA); cell.setCellFormula("SUM(Sheet1:Sheet3!A1:B1)"); wb.getCreationHelper().createFormulaEvaluator().evaluateAll(); @@ -416,8 +417,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { XSSFSheet sheet = wb.createSheet("test"); XSSFRow row = sheet.createRow(0); XSSFRow row2 = sheet.createRow(1); - XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA); - XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC); + XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA); + XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC); cellB1.setCellValue(10); XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); cellA2.setCellFormula("IF(B1=0,\"\",((ROW()-ROW(A$1))*12))"); @@ -441,8 +442,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { XSSFSheet sheet = wb.createSheet("test"); XSSFRow row = sheet.createRow(0); XSSFRow row2 = sheet.createRow(1); - XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA); - XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC); + XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA); + XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC); cellB1.setCellValue(10); XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); cellA2.setCellFormula("IF(B1=0,\"\",((ROW(A$1))))"); @@ -466,8 +467,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { XSSFSheet sheet = wb.createSheet("test"); XSSFRow row = sheet.createRow(0); XSSFRow row2 = sheet.createRow(1); - XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA); - XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC); + XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA); + XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC); cellB1.setCellValue(10); XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); @@ -492,8 +493,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { XSSFSheet sheet = wb.createSheet("test"); XSSFRow row = sheet.createRow(0); XSSFRow row2 = sheet.createRow(1); - XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA); - XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC); + XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA); + XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC); cellB1.setCellValue(10); XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); @@ -512,8 +513,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { XSSFSheet sheet = wb.createSheet("test"); XSSFRow row = sheet.createRow(0); XSSFRow row2 = sheet.createRow(1); - XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA); - XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC); + XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA); + XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC); cellB1.setCellValue(10); XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); @@ -532,8 +533,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { XSSFSheet sheet = wb.createSheet("test"); XSSFRow row = sheet.createRow(0); XSSFRow row2 = sheet.createRow(1); - XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA); - XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC); + XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA); + XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC); cellB1.setCellValue(10); XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); @@ -552,8 +553,8 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { XSSFSheet sheet = wb.createSheet("test"); XSSFRow row = sheet.createRow(0); XSSFRow row2 = sheet.createRow(1); - XSSFCell cellA2 = row2.createCell(0, Cell.CELL_TYPE_FORMULA); - XSSFCell cellB1 = row.createCell(1, Cell.CELL_TYPE_NUMERIC); + XSSFCell cellA2 = row2.createCell(0, CellType.FORMULA); + XSSFCell cellB1 = row.createCell(1, CellType.NUMERIC); cellB1.setCellValue(10); XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); @@ -575,9 +576,9 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { wb.getCreationHelper().createFormulaEvaluator().evaluateAll(); - assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 0,0).getCachedFormulaResultType()); + assertEquals(CellType.ERROR, getCell(sheet, 0,0).getCachedFormulaResultType()); assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0,0).getErrorCellValue()); - assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 0,1).getCachedFormulaResultType()); + assertEquals(CellType.ERROR, getCell(sheet, 0,1).getCachedFormulaResultType()); assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0,1).getErrorCellValue()); wb.close(); @@ -596,11 +597,11 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { wb.getCreationHelper().createFormulaEvaluator().evaluateAll(); - assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 0, 0).getCachedFormulaResultType()); + assertEquals(CellType.ERROR, getCell(sheet, 0, 0).getCachedFormulaResultType()); assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0, 0).getErrorCellValue()); - assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 1, 0).getCachedFormulaResultType()); + assertEquals(CellType.ERROR, getCell(sheet, 1, 0).getCachedFormulaResultType()); assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 1, 0).getErrorCellValue()); - assertEquals(XSSFCell.CELL_TYPE_ERROR, getCell(sheet, 0, 3).getCachedFormulaResultType()); + assertEquals(CellType.ERROR, getCell(sheet, 0, 3).getCachedFormulaResultType()); assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0, 3).getErrorCellValue()); wb.close(); @@ -639,7 +640,7 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { if (cell == null) { cell = r.createCell(column); } - cell.setCellType(XSSFCell.CELL_TYPE_FORMULA); + cell.setCellType(CellType.FORMULA); cell.setCellFormula(formula); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java index 08c4ed2984..119157f682 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java @@ -370,12 +370,12 @@ public final class TestXSSFFormulaParser { assertEquals("MIN", toFormulaString(ptgs[1], fpb)); // Check we can round-trip - try to set a new one to a new single cell - Cell newF = s1.getRow(0).createCell(10, Cell.CELL_TYPE_FORMULA); + Cell newF = s1.getRow(0).createCell(10, CellType.FORMULA); newF.setCellFormula("SUM(Sheet2:Sheet3!A1)"); assertEquals("SUM(Sheet2:Sheet3!A1)", newF.getCellFormula()); // Check we can round-trip - try to set a new one to a cell range - newF = s1.getRow(0).createCell(11, Cell.CELL_TYPE_FORMULA); + newF = s1.getRow(0).createCell(11, CellType.FORMULA); newF.setCellFormula("MIN(Sheet1:Sheet2!A1:B2)"); assertEquals("MIN(Sheet1:Sheet2!A1:B2)", newF.getCellFormula()); @@ -465,7 +465,7 @@ public final class TestXSSFFormulaParser { for (Row row : xsheet) { for (Cell cell : row) { - if (cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA) { + if (cell.getCellType() == CellType.FORMULA) { try { evaluator.evaluateFormulaCell(cell); } catch (Exception e) { diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java index 9f90202e0f..fd815e9e03 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java @@ -16,9 +16,8 @@ ==================================================================== */ package org.apache.poi.xssf.usermodel; -import junit.framework.TestCase; - import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.DataConsolidateFunction; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Workbook; @@ -30,6 +29,8 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotFields; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotTableDefinition; import org.openxmlformats.schemas.spreadsheetml.x2006.main.STDataConsolidateFunction; +import junit.framework.TestCase; + public class TestXSSFPivotTable extends TestCase { private XSSFPivotTable pivotTable; private XSSFPivotTable offsetPivotTable; @@ -316,7 +317,7 @@ public class TestXSSFPivotTable extends TestCase { */ public void testAddDataColumnWithOffsetData() { offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1); - assertEquals(Cell.CELL_TYPE_NUMERIC, offsetOuterCell.getCellType()); + assertEquals(CellType.NUMERIC, offsetOuterCell.getCellType()); offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 0); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java index c83336b7d6..9db9171e1e 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java @@ -26,6 +26,7 @@ import java.io.IOException; import org.apache.poi.ss.usermodel.BaseTestXRow; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellCopyPolicy; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.xssf.XSSFITestDataProvider; @@ -182,7 +183,7 @@ public final class TestXSSFRow extends BaseTestXRow { assertSame("existing references to externObserverRow are still valid", externObserverRow, sheet2.getRow(0)); // Make sure copyRowFrom actually copied row (this is tested elsewhere) - assertEquals(Cell.CELL_TYPE_STRING, destRow.getCell(0).getCellType()); + assertEquals(CellType.STRING, destRow.getCell(0).getCellType()); assertEquals("hello", destRow.getCell(0).getStringCellValue()); // We don't want #REF! errors if we copy a row that contains cells that are referred to by other cells outside of copied region diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java index 70df48c2df..f8681fd002 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java @@ -45,6 +45,7 @@ import org.apache.poi.ss.usermodel.AutoFilter; import org.apache.poi.ss.usermodel.BaseTestXSheet; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellCopyPolicy; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.ClientAnchor; import org.apache.poi.ss.usermodel.FormulaError; import org.apache.poi.ss.usermodel.IgnoredErrorType; @@ -1483,44 +1484,44 @@ public final class TestXSSFSheet extends BaseTestXSheet { // Blank cell = CellUtil.getCell(destRow, col++); - assertEquals("[Blank] C7 cell type", Cell.CELL_TYPE_BLANK, cell.getCellType()); + assertEquals("[Blank] C7 cell type", CellType.BLANK, cell.getCellType()); // Error cell = CellUtil.getCell(destRow, col++); - assertEquals("[Error] D7 cell type", Cell.CELL_TYPE_ERROR, cell.getCellType()); + assertEquals("[Error] D7 cell type", CellType.ERROR, cell.getCellType()); final FormulaError error = FormulaError.forInt(cell.getErrorCellValue()); assertEquals("[Error] D7 cell value", FormulaError.NA, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here // Date cell = CellUtil.getCell(destRow, col++); - assertEquals("[Date] E7 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType()); + assertEquals("[Date] E7 cell type", CellType.NUMERIC, cell.getCellType()); final Date date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 1).getTime(); assertEquals("[Date] E7 cell value", date, cell.getDateCellValue()); // Boolean cell = CellUtil.getCell(destRow, col++); - assertEquals("[Boolean] F7 cell type", Cell.CELL_TYPE_BOOLEAN, cell.getCellType()); + assertEquals("[Boolean] F7 cell type", CellType.BOOLEAN, cell.getCellType()); assertEquals("[Boolean] F7 cell value", true, cell.getBooleanCellValue()); // String cell = CellUtil.getCell(destRow, col++); - assertEquals("[String] G7 cell type", Cell.CELL_TYPE_STRING, cell.getCellType()); + assertEquals("[String] G7 cell type", CellType.STRING, cell.getCellType()); assertEquals("[String] G7 cell value", "Hello", cell.getStringCellValue()); // Int cell = CellUtil.getCell(destRow, col++); - assertEquals("[Int] H7 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType()); + assertEquals("[Int] H7 cell type", CellType.NUMERIC, cell.getCellType()); assertEquals("[Int] H7 cell value", 15, (int) cell.getNumericCellValue()); // Float cell = CellUtil.getCell(destRow, col++); - assertEquals("[Float] I7 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType()); + assertEquals("[Float] I7 cell type", CellType.NUMERIC, cell.getCellType()); assertEquals("[Float] I7 cell value", 12.5, cell.getNumericCellValue(), FLOAT_PRECISION); // Cell Formula cell = CellUtil.getCell(destRow, col++); assertEquals("J7", new CellReference(cell).formatAsString()); - assertEquals("[Cell Formula] J7 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType()); + assertEquals("[Cell Formula] J7 cell type", CellType.FORMULA, cell.getCellType()); assertEquals("[Cell Formula] J7 cell formula", "5+2", cell.getCellFormula()); System.out.println("Cell formula evaluation currently unsupported"); @@ -1529,21 +1530,21 @@ public final class TestXSSFSheet extends BaseTestXSheet { cell = CellUtil.getCell(destRow, col++); assertEquals("K7", new CellReference(cell).formatAsString()); assertEquals("[Cell Formula with Reference] K7 cell type", - Cell.CELL_TYPE_FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellType()); assertEquals("[Cell Formula with Reference] K7 cell formula", "J7+H$2", cell.getCellFormula()); // Cell Formula with Reference spanning multiple rows cell = CellUtil.getCell(destRow, col++); assertEquals("[Cell Formula with Reference spanning multiple rows] L7 cell type", - Cell.CELL_TYPE_FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellType()); assertEquals("[Cell Formula with Reference spanning multiple rows] L7 cell formula", "G7&\" \"&G8", cell.getCellFormula()); // Cell Formula with Reference spanning multiple rows cell = CellUtil.getCell(destRow, col++); assertEquals("[Cell Formula with Area Reference] M7 cell type", - Cell.CELL_TYPE_FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellType()); assertEquals("[Cell Formula with Area Reference] M7 cell formula", "SUM(H7:I8)", cell.getCellFormula()); @@ -1552,13 +1553,13 @@ public final class TestXSSFSheet extends BaseTestXSheet { System.out.println("Array formulas currently unsupported"); // FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula() /* - assertEquals("[Array Formula] N7 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType()); + assertEquals("[Array Formula] N7 cell type", CellType.FORMULA, cell.getCellType()); assertEquals("[Array Formula] N7 cell formula", "{SUM(H7:J7*{1,2,3})}", cell.getCellFormula()); */ // Data Format cell = CellUtil.getCell(destRow, col++); - assertEquals("[Data Format] O7 cell type;", Cell.CELL_TYPE_NUMERIC, cell.getCellType()); + assertEquals("[Data Format] O7 cell type;", CellType.NUMERIC, cell.getCellType()); assertEquals("[Data Format] O7 cell value", 100.20, cell.getNumericCellValue(), FLOAT_PRECISION); //FIXME: currently fails final String moneyFormat = "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)"; @@ -1637,83 +1638,83 @@ public final class TestXSSFSheet extends BaseTestXSheet { // Blank col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Blank] C10 cell type", Cell.CELL_TYPE_BLANK, cell.getCellType()); + assertEquals("[Blank] C10 cell type", CellType.BLANK, cell.getCellType()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Blank] C11 cell type", Cell.CELL_TYPE_BLANK, cell.getCellType()); + assertEquals("[Blank] C11 cell type", CellType.BLANK, cell.getCellType()); // Error col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Error] D10 cell type", Cell.CELL_TYPE_ERROR, cell.getCellType()); + assertEquals("[Error] D10 cell type", CellType.ERROR, cell.getCellType()); FormulaError error = FormulaError.forInt(cell.getErrorCellValue()); assertEquals("[Error] D10 cell value", FormulaError.NA, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here cell = CellUtil.getCell(destRow2, col); - assertEquals("[Error] D11 cell type", Cell.CELL_TYPE_ERROR, cell.getCellType()); + assertEquals("[Error] D11 cell type", CellType.ERROR, cell.getCellType()); error = FormulaError.forInt(cell.getErrorCellValue()); assertEquals("[Error] D11 cell value", FormulaError.NAME, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here // Date col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Date] E10 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType()); + assertEquals("[Date] E10 cell type", CellType.NUMERIC, cell.getCellType()); Date date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 1).getTime(); assertEquals("[Date] E10 cell value", date, cell.getDateCellValue()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Date] E11 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType()); + assertEquals("[Date] E11 cell type", CellType.NUMERIC, cell.getCellType()); date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 2).getTime(); assertEquals("[Date] E11 cell value", date, cell.getDateCellValue()); // Boolean col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Boolean] F10 cell type", Cell.CELL_TYPE_BOOLEAN, cell.getCellType()); + assertEquals("[Boolean] F10 cell type", CellType.BOOLEAN, cell.getCellType()); assertEquals("[Boolean] F10 cell value", true, cell.getBooleanCellValue()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Boolean] F11 cell type", Cell.CELL_TYPE_BOOLEAN, cell.getCellType()); + assertEquals("[Boolean] F11 cell type", CellType.BOOLEAN, cell.getCellType()); assertEquals("[Boolean] F11 cell value", false, cell.getBooleanCellValue()); // String col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[String] G10 cell type", Cell.CELL_TYPE_STRING, cell.getCellType()); + assertEquals("[String] G10 cell type", CellType.STRING, cell.getCellType()); assertEquals("[String] G10 cell value", "Hello", cell.getStringCellValue()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[String] G11 cell type", Cell.CELL_TYPE_STRING, cell.getCellType()); + assertEquals("[String] G11 cell type", CellType.STRING, cell.getCellType()); assertEquals("[String] G11 cell value", "World", cell.getStringCellValue()); // Int col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Int] H10 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType()); + assertEquals("[Int] H10 cell type", CellType.NUMERIC, cell.getCellType()); assertEquals("[Int] H10 cell value", 15, (int) cell.getNumericCellValue()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Int] H11 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType()); + assertEquals("[Int] H11 cell type", CellType.NUMERIC, cell.getCellType()); assertEquals("[Int] H11 cell value", 42, (int) cell.getNumericCellValue()); // Float col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Float] I10 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType()); + assertEquals("[Float] I10 cell type", CellType.NUMERIC, cell.getCellType()); assertEquals("[Float] I10 cell value", 12.5, cell.getNumericCellValue(), FLOAT_PRECISION); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Float] I11 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType()); + assertEquals("[Float] I11 cell type", CellType.NUMERIC, cell.getCellType()); assertEquals("[Float] I11 cell value", 5.5, cell.getNumericCellValue(), FLOAT_PRECISION); // Cell Formula col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Cell Formula] J10 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType()); + assertEquals("[Cell Formula] J10 cell type", CellType.FORMULA, cell.getCellType()); assertEquals("[Cell Formula] J10 cell formula", "5+2", cell.getCellFormula()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Cell Formula] J11 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType()); + assertEquals("[Cell Formula] J11 cell type", CellType.FORMULA, cell.getCellType()); assertEquals("[Cell Formula] J11 cell formula", "6+18", cell.getCellFormula()); // Cell Formula with Reference @@ -1721,25 +1722,25 @@ public final class TestXSSFSheet extends BaseTestXSheet { // Formula row references should be adjusted by destRowNum-srcRowNum cell = CellUtil.getCell(destRow1, col); assertEquals("[Cell Formula with Reference] K10 cell type", - Cell.CELL_TYPE_FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellType()); assertEquals("[Cell Formula with Reference] K10 cell formula", "J10+H$2", cell.getCellFormula()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Cell Formula with Reference] K11 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType()); + assertEquals("[Cell Formula with Reference] K11 cell type", CellType.FORMULA, cell.getCellType()); assertEquals("[Cell Formula with Reference] K11 cell formula", "J11+H$2", cell.getCellFormula()); // Cell Formula with Reference spanning multiple rows col++; cell = CellUtil.getCell(destRow1, col); assertEquals("[Cell Formula with Reference spanning multiple rows] L10 cell type", - Cell.CELL_TYPE_FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellType()); assertEquals("[Cell Formula with Reference spanning multiple rows] L10 cell formula", "G10&\" \"&G11", cell.getCellFormula()); cell = CellUtil.getCell(destRow2, col); assertEquals("[Cell Formula with Reference spanning multiple rows] L11 cell type", - Cell.CELL_TYPE_FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellType()); assertEquals("[Cell Formula with Reference spanning multiple rows] L11 cell formula", "G11&\" \"&G12", cell.getCellFormula()); @@ -1747,13 +1748,13 @@ public final class TestXSSFSheet extends BaseTestXSheet { col++; cell = CellUtil.getCell(destRow1, col); assertEquals("[Cell Formula with Area Reference] M10 cell type", - Cell.CELL_TYPE_FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellType()); assertEquals("[Cell Formula with Area Reference] M10 cell formula", "SUM(H10:I11)", cell.getCellFormula()); cell = CellUtil.getCell(destRow2, col); assertEquals("[Cell Formula with Area Reference] M11 cell type", - Cell.CELL_TYPE_FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellType()); assertEquals("[Cell Formula with Area Reference] M11 cell formula", "SUM($H$3:I10)", cell.getCellFormula()); //Also acceptable: SUM($H10:I$3), but this AreaReference isn't in ascending order @@ -1763,19 +1764,19 @@ public final class TestXSSFSheet extends BaseTestXSheet { // System.out.println("Array formulas currently unsupported"); /* // FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula() - assertEquals("[Array Formula] N10 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType()); + assertEquals("[Array Formula] N10 cell type", CellType.FORMULA, cell.getCellType()); assertEquals("[Array Formula] N10 cell formula", "{SUM(H10:J10*{1,2,3})}", cell.getCellFormula()); cell = CellUtil.getCell(destRow2, col); // FIXME: Array Formula set with Sheet.setArrayFormula() instead of cell.setFormula() - assertEquals("[Array Formula] N11 cell type", Cell.CELL_TYPE_FORMULA, cell.getCellType()); + assertEquals("[Array Formula] N11 cell type", CellType.FORMULA, cell.getCellType()); assertEquals("[Array Formula] N11 cell formula", "{SUM(H11:J11*{1,2,3})}", cell.getCellFormula()); */ // Data Format col++; cell = CellUtil.getCell(destRow2, col); - assertEquals("[Data Format] O10 cell type", Cell.CELL_TYPE_NUMERIC, cell.getCellType()); + assertEquals("[Data Format] O10 cell type", CellType.NUMERIC, cell.getCellType()); assertEquals("[Data Format] O10 cell value", 100.20, cell.getNumericCellValue(), FLOAT_PRECISION); final String moneyFormat = "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)"; assertEquals("[Data Format] O10 cell data format", moneyFormat, cell.getCellStyle().getDataFormatString()); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java index a527dbec15..24f9e37b29 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java @@ -26,6 +26,7 @@ import java.io.IOException; import org.apache.poi.ss.usermodel.BaseTestSheetShiftRows; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Comment; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; @@ -116,7 +117,7 @@ public final class TestXSSFSheetShiftRows extends BaseTestSheetShiftRows { return; } Cell readCell = readRow.getCell(0); - if(readCell.getCellType() == Cell.CELL_TYPE_NUMERIC) { + if(readCell.getCellType() == CellType.NUMERIC) { assertEquals(expect, Double.toString(readCell.getNumericCellValue())); } else { assertEquals(expect, readCell.getStringCellValue()); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/QuickTest.java b/src/scratchpad/src/org/apache/poi/hwpf/QuickTest.java index ec97cb4c10..eeb17abe3b 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/QuickTest.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/QuickTest.java @@ -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; diff --git a/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java b/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java index 7fd2850df9..53f5f4ac75 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java +++ b/src/testcases/org/apache/poi/hssf/model/TestFormulaParserEval.java @@ -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); } } diff --git a/src/testcases/org/apache/poi/hssf/model/TestRVA.java b/src/testcases/org/apache/poi/hssf/model/TestRVA.java index e1345c2e9d..48d0066cf0 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestRVA.java +++ b/src/testcases/org/apache/poi/hssf/model/TestRVA.java @@ -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; } diff --git a/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java b/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java index 14de4bcdaf..bf7b813d0a 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestSharedFormulaRecord.java @@ -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); } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java index 6fdfb0fe33..f0f95261a7 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java @@ -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 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(); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java index cba7a6615e..e5aad2afc4 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java @@ -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()); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestExternalReferenceChange.java b/src/testcases/org/apache/poi/hssf/usermodel/TestExternalReferenceChange.java index 87408b9f59..86d59d8c74 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestExternalReferenceChange.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestExternalReferenceChange.java @@ -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); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java index eb59e8a751..82124ffc80 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java @@ -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(); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java index d2c9d0753c..902884653d 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java @@ -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()); } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java index 7dfd8f3911..69842b4d4d 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java @@ -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()); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java index 8258bfb9ff..4b1e0677e0 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java @@ -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); diff --git a/src/testcases/org/apache/poi/ss/format/TestCellFormat.java b/src/testcases/org/apache/poi/ss/format/TestCellFormat.java index 6f4ed58ee2..5d19c633f4 100644 --- a/src/testcases/org/apache/poi/ss/format/TestCellFormat.java +++ b/src/testcases/org/apache/poi/ss/format/TestCellFormat.java @@ -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); diff --git a/src/testcases/org/apache/poi/ss/formula/BaseTestExternalFunctions.java b/src/testcases/org/apache/poi/ss/formula/BaseTestExternalFunctions.java index 0043187c05..d2b6577345 100644 --- a/src/testcases/org/apache/poi/ss/formula/BaseTestExternalFunctions.java +++ b/src/testcases/org/apache/poi/ss/formula/BaseTestExternalFunctions.java @@ -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(); } diff --git a/src/testcases/org/apache/poi/ss/formula/TestEvaluationCache.java b/src/testcases/org/apache/poi/ss/formula/TestEvaluationCache.java index 1c626dcee1..c469b5cdcd 100644 --- a/src/testcases/org/apache/poi/ss/formula/TestEvaluationCache.java +++ b/src/testcases/org/apache/poi/ss/formula/TestEvaluationCache.java @@ -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); diff --git a/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java b/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java index 35bb050b1a..004097c822 100644 --- a/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java +++ b/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java @@ -27,6 +27,7 @@ import junit.framework.TestCase; 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.FormulaEvaluator; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; @@ -66,7 +67,7 @@ public class TestMissingWorkbook extends TestCase { Row lARow = lSheet.getRow(0); Cell lA1Cell = lARow.getCell(0); - assertEquals(Cell.CELL_TYPE_FORMULA, lA1Cell.getCellType()); + assertEquals(CellType.FORMULA, lA1Cell.getCellType()); try { evaluator.evaluateFormulaCell(lA1Cell); fail("Missing external workbook reference exception expected!"); @@ -81,9 +82,9 @@ public class TestMissingWorkbook extends TestCase { Cell lB1Cell = lSheet.getRow(1).getCell(0); Cell lC1Cell = lSheet.getRow(2).getCell(0); - assertEquals(Cell.CELL_TYPE_FORMULA, lA1Cell.getCellType()); - assertEquals(Cell.CELL_TYPE_FORMULA, lB1Cell.getCellType()); - assertEquals(Cell.CELL_TYPE_FORMULA, lC1Cell.getCellType()); + assertEquals(CellType.FORMULA, lA1Cell.getCellType()); + assertEquals(CellType.FORMULA, lB1Cell.getCellType()); + assertEquals(CellType.FORMULA, lC1Cell.getCellType()); // Check cached values assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d); @@ -94,9 +95,9 @@ public class TestMissingWorkbook extends TestCase { FormulaEvaluator evaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator(); evaluator.setIgnoreMissingWorkbooks(true); - assertEquals(Cell.CELL_TYPE_NUMERIC, evaluator.evaluateFormulaCell(lA1Cell)); - assertEquals(Cell.CELL_TYPE_STRING, evaluator.evaluateFormulaCell(lB1Cell)); - assertEquals(Cell.CELL_TYPE_BOOLEAN, evaluator.evaluateFormulaCell(lC1Cell)); + assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(lA1Cell)); + assertEquals(CellType.STRING, evaluator.evaluateFormulaCell(lB1Cell)); + assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(lC1Cell)); assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d); assertEquals("POI rocks!", lB1Cell.getStringCellValue()); @@ -110,9 +111,9 @@ public class TestMissingWorkbook extends TestCase { Cell lB1Cell = lSheet.getRow(1).getCell(0); Cell lC1Cell = lSheet.getRow(2).getCell(0); - assertEquals(Cell.CELL_TYPE_FORMULA, lA1Cell.getCellType()); - assertEquals(Cell.CELL_TYPE_FORMULA, lB1Cell.getCellType()); - assertEquals(Cell.CELL_TYPE_FORMULA, lC1Cell.getCellType()); + assertEquals(CellType.FORMULA, lA1Cell.getCellType()); + assertEquals(CellType.FORMULA, lB1Cell.getCellType()); + assertEquals(CellType.FORMULA, lC1Cell.getCellType()); FormulaEvaluator lMainWorkbookEvaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator(); FormulaEvaluator lSourceEvaluator = sourceWorkbook.getCreationHelper().createFormulaEvaluator(); @@ -121,9 +122,9 @@ public class TestMissingWorkbook extends TestCase { workbooks.put(SOURCE_DUMMY_WORKBOOK_FILENAME, lSourceEvaluator); lMainWorkbookEvaluator.setupReferencedWorkbooks(workbooks); - assertEquals(Cell.CELL_TYPE_NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCell(lA1Cell)); - assertEquals(Cell.CELL_TYPE_STRING, lMainWorkbookEvaluator.evaluateFormulaCell(lB1Cell)); - assertEquals(Cell.CELL_TYPE_BOOLEAN, lMainWorkbookEvaluator.evaluateFormulaCell(lC1Cell)); + assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCell(lA1Cell)); + assertEquals(CellType.STRING, lMainWorkbookEvaluator.evaluateFormulaCell(lB1Cell)); + assertEquals(CellType.BOOLEAN, lMainWorkbookEvaluator.evaluateFormulaCell(lC1Cell)); assertEquals(20.0d, lA1Cell.getNumericCellValue(), 0.00001d); assertEquals("Apache rocks!", lB1Cell.getStringCellValue()); diff --git a/src/testcases/org/apache/poi/ss/formula/atp/TestIfError.java b/src/testcases/org/apache/poi/ss/formula/atp/TestIfError.java index 7a70fee262..1d956c76fa 100644 --- a/src/testcases/org/apache/poi/ss/formula/atp/TestIfError.java +++ b/src/testcases/org/apache/poi/ss/formula/atp/TestIfError.java @@ -16,16 +16,17 @@ ==================================================================== */ 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()); } diff --git a/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java b/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java index 6b8d50322e..802b7d8b33 100644 --- a/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java +++ b/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java @@ -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()); } diff --git a/src/testcases/org/apache/poi/ss/formula/atp/TestYearFracCalculatorFromSpreadsheet.java b/src/testcases/org/apache/poi/ss/formula/atp/TestYearFracCalculatorFromSpreadsheet.java index 4860d6b05e..f52d0728e6 100644 --- a/src/testcases/org/apache/poi/ss/formula/atp/TestYearFracCalculatorFromSpreadsheet.java +++ b/src/testcases/org/apache/poi/ss/formula/atp/TestYearFracCalculatorFromSpreadsheet.java @@ -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); diff --git a/src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java b/src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java index e82fcf7517..4c0223afd7 100644 --- a/src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java +++ b/src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java @@ -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(); diff --git a/src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java b/src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java index 451b840713..561ce4bfda 100644 --- a/src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java +++ b/src/testcases/org/apache/poi/ss/formula/eval/TestFormulaBugs.java @@ -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(); diff --git a/src/testcases/org/apache/poi/ss/formula/eval/TestPercentEval.java b/src/testcases/org/apache/poi/ss/formula/eval/TestPercentEval.java index faeee6af3e..c3a5eec233 100644 --- a/src/testcases/org/apache/poi/ss/formula/eval/TestPercentEval.java +++ b/src/testcases/org/apache/poi/ss/formula/eval/TestPercentEval.java @@ -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); } } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/CountifsTests.java b/src/testcases/org/apache/poi/ss/formula/functions/CountifsTests.java index 94a5c86e92..af0d7fbde0 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/CountifsTests.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/CountifsTests.java @@ -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); diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestAddress.java b/src/testcases/org/apache/poi/ss/formula/functions/TestAddress.java index 013b15806c..8f3951aa91 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestAddress.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestAddress.java @@ -19,6 +19,7 @@ package org.apache.poi.ss.formula.functions; 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 junit.framework.TestCase; @@ -72,7 +73,7 @@ public final class TestAddress extends TestCase { cell.setCellFormula(formulaText); fe.notifyUpdateCell(cell); CellValue result = fe.evaluate(cell); - assertEquals(result.getCellType(), HSSFCell.CELL_TYPE_STRING); + assertEquals(result.getCellType(), CellType.STRING); assertEquals(expectedResult, result.getStringValue()); } } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestCalendarFieldFunction.java b/src/testcases/org/apache/poi/ss/formula/functions/TestCalendarFieldFunction.java index 636c72a427..3f88237293 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestCalendarFieldFunction.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestCalendarFieldFunction.java @@ -17,16 +17,16 @@ 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(); diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestClean.java b/src/testcases/org/apache/poi/ss/formula/functions/TestClean.java index ad717b162e..fe6c6a6ed5 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestClean.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestClean.java @@ -19,6 +19,7 @@ package org.apache.poi.ss.formula.functions; 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 junit.framework.TestCase; @@ -59,7 +60,7 @@ public final class TestClean extends TestCase { cell.setCellFormula(formulaText); fe.notifyUpdateCell(cell); CellValue result = fe.evaluate(cell); - assertEquals(result.getCellType(), HSSFCell.CELL_TYPE_STRING); + assertEquals(result.getCellType(), CellType.STRING); assertEquals(expectedResult, result.getStringValue()); } } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java b/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java index fd3bc4b7b7..6dff5eda3c 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java @@ -17,10 +17,12 @@ 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(); diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestDate.java b/src/testcases/org/apache/poi/ss/formula/functions/TestDate.java index 64e1c45542..ae3d5846ae 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestDate.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestDate.java @@ -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(); diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestFind.java b/src/testcases/org/apache/poi/ss/formula/functions/TestFind.java index d9eb226bfc..0bfff626af 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestFind.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestFind.java @@ -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()); } } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestFixed.java b/src/testcases/org/apache/poi/ss/formula/functions/TestFixed.java index 8624898d57..e14ea3c45b 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestFixed.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestFixed.java @@ -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()); } } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java b/src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java index c2118a147d..8e93152c81 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestIndirect.java @@ -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(); diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestIrr.java b/src/testcases/org/apache/poi/ss/formula/functions/TestIrr.java index 7606d3fefa..b16fe50009 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestIrr.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestIrr.java @@ -17,12 +17,18 @@ 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% } } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestIsBlank.java b/src/testcases/org/apache/poi/ss/formula/functions/TestIsBlank.java index 6b40f9c173..51b80876ec 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestIsBlank.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestIsBlank.java @@ -17,14 +17,15 @@ 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()); } } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestLogicalFunction.java b/src/testcases/org/apache/poi/ss/formula/functions/TestLogicalFunction.java index 628df033d0..52b72dfa25 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestLogicalFunction.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestLogicalFunction.java @@ -19,9 +19,9 @@ package org.apache.poi.ss.formula.functions; import java.io.IOException; -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.CellValue; import org.apache.poi.ss.usermodel.FormulaEvaluator; import org.apache.poi.ss.usermodel.Row; @@ -29,6 +29,8 @@ 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; + /** * LogicalFunction unit tests. */ @@ -55,11 +57,11 @@ public class TestLogicalFunction extends TestCase { Row row2 = sh.createRow(1); row3 = sh.createRow(2); - row1.createCell(0, Cell.CELL_TYPE_NUMERIC); - row1.createCell(1, Cell.CELL_TYPE_NUMERIC); + row1.createCell(0, CellType.NUMERIC); + row1.createCell(1, CellType.NUMERIC); - row2.createCell(0, Cell.CELL_TYPE_NUMERIC); - row2.createCell(1, Cell.CELL_TYPE_NUMERIC); + row2.createCell(0, CellType.NUMERIC); + row2.createCell(1, CellType.NUMERIC); row3.createCell(0); row3.createCell(1); diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestMirr.java b/src/testcases/org/apache/poi/ss/formula/functions/TestMirr.java index a934202ed1..0fe105c634 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestMirr.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestMirr.java @@ -17,9 +17,6 @@ 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; @@ -28,8 +25,12 @@ 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.formula.eval.EvaluationException; +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 org.apache.poi.ss.formula.functions.Mirr} * @@ -161,7 +162,7 @@ public final class TestMirr 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-8); } } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestNper.java b/src/testcases/org/apache/poi/ss/formula/functions/TestNper.java index fe3b41122f..ec5553d84c 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestNper.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestNper.java @@ -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(); } diff --git a/src/testcases/org/apache/poi/ss/formula/udf/TestAggregatingUDFFinder.java b/src/testcases/org/apache/poi/ss/formula/udf/TestAggregatingUDFFinder.java index 76e175d5c9..88d7e84fff 100644 --- a/src/testcases/org/apache/poi/ss/formula/udf/TestAggregatingUDFFinder.java +++ b/src/testcases/org/apache/poi/ss/formula/udf/TestAggregatingUDFFinder.java @@ -16,11 +16,7 @@ ==================================================================== */ 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 { diff --git a/src/testcases/org/apache/poi/ss/formula/udf/TestDefaultUDFFinder.java b/src/testcases/org/apache/poi/ss/formula/udf/TestDefaultUDFFinder.java index 6647276097..010b19d4e2 100644 --- a/src/testcases/org/apache/poi/ss/formula/udf/TestDefaultUDFFinder.java +++ b/src/testcases/org/apache/poi/ss/formula/udf/TestDefaultUDFFinder.java @@ -16,10 +16,7 @@ ==================================================================== */ 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 { diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java index a1c91481a5..9570341fd6 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java @@ -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); diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java index 120216bd7f..27ac4c93a8 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java @@ -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(); } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java index 0d3611992c..f587b640a3 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java @@ -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); } } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java index b16645e8f6..ac6037b42c 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetShiftRows.java @@ -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); } } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java index 58919167fd..7bfc606ec3 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java @@ -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 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 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 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 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()); } */ diff --git a/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java b/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java index 95d173aa3e..c4903214a0 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java +++ b/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java @@ -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)); diff --git a/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java b/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java index ee90ee6c5a..7a668b016d 100644 --- a/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java +++ b/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java @@ -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() {