You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/07/04 11:54:20 UTC
svn commit: r1751256 [1/3] - in /poi/trunk/src:
examples/src/org/apache/poi/hssf/usermodel/examples/
examples/src/org/apache/poi/hssf/view/
examples/src/org/apache/poi/ss/examples/
examples/src/org/apache/poi/ss/examples/html/ java/org/apache/poi/hssf/...
Author: onealj
Date: Mon Jul 4 11:54:20 2016
New Revision: 1751256
URL: http://svn.apache.org/viewvc?rev=1751256&view=rev
Log:
bug 59791: getCellType and getCachedFormulaResultType should return an integer for backwards compatibility
Modified:
poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java
poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java
poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java
poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java
poi/trunk/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java
poi/trunk/src/examples/src/org/apache/poi/ss/examples/ToCSV.java
poi/trunk/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java
poi/trunk/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationCell.java
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
poi/trunk/src/java/org/apache/poi/ss/format/CellFormat.java
poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationCache.java
poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationCell.java
poi/trunk/src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java
poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java
poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluator.java
poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java
poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
poi/trunk/src/java/org/apache/poi/ss/util/SheetUtil.java
poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationCell.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java
poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java
poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java
poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java
poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRVA.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestExternalReferenceChange.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java
poi/trunk/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java
poi/trunk/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java
poi/trunk/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java
poi/trunk/src/testcases/org/apache/poi/ss/formula/atp/TestYearFracCalculatorFromSpreadsheet.java
poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/TestFormulasFromSpreadsheet.java
poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java
poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/BaseTestFunctionsFromSpreadsheet.java
poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java
poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/TestNper.java
poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java
poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java
poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java
poi/trunk/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java
Modified: poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java Mon Jul 4 11:54:20 2016
@@ -185,7 +185,7 @@ public final class HSSFReadWrite {
HSSFCell cell = row.getCell(c);
String value = null;
- switch (cell.getCellType()) {
+ switch (cell.getCellTypeEnum()) {
case FORMULA:
value = "FORMULA value=" + cell.getCellFormula();
Modified: poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java Mon Jul 4 11:54:20 2016
@@ -142,7 +142,7 @@ public class SVSheetTable extends JTable
HSSFCell cell = (HSSFCell) getValueAt(row, col);
String formula = "";
if (cell != null) {
- if (cell.getCellType() == CellType.FORMULA) {
+ if (cell.getCellTypeEnum() == CellType.FORMULA) {
formula = cell.getCellFormula();
} else {
formula = cell.toString();
Modified: poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java Mon Jul 4 11:54:20 2016
@@ -151,7 +151,7 @@ public class SVTableCellEditor extends A
//Set the value that is rendered for the cell
- switch (cell.getCellType()) {
+ switch (cell.getCellTypeEnum()) {
case BLANK:
editor.setText("");
break;
Modified: poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java Mon Jul 4 11:54:20 2016
@@ -165,7 +165,7 @@ public class SVTableCellRenderer extends
isBorderSet=true;
//Set the value that is rendered for the cell
- switch (c.getCellType()) {
+ switch (c.getCellTypeEnum()) {
case BLANK:
setValue("");
break;
Modified: poi/trunk/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java Mon Jul 4 11:54:20 2016
@@ -179,7 +179,7 @@ public class ExcelComparator {
private void compareDataInCell(Locator loc1, Locator loc2) {
if (isCellTypeMatches(loc1, loc2)) {
- final CellType loc1cellType = loc1.cell.getCellType();
+ final CellType loc1cellType = loc1.cell.getCellTypeEnum();
switch(loc1cellType) {
case BLANK:
case STRING:
@@ -581,8 +581,8 @@ public class ExcelComparator {
* Checks if cell type matches.
*/
private boolean isCellTypeMatches(Locator loc1, Locator loc2) {
- CellType type1 = loc1.cell.getCellType();
- CellType type2 = loc2.cell.getCellType();
+ CellType type1 = loc1.cell.getCellTypeEnum();
+ CellType type2 = loc2.cell.getCellTypeEnum();
if (type1 == type2) return true;
addMessage(loc1, loc2,
"Cell Data-Type does not Match in :: ",
Modified: poi/trunk/src/examples/src/org/apache/poi/ss/examples/ToCSV.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/ss/examples/ToCSV.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/ss/examples/ToCSV.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/ss/examples/ToCSV.java Mon Jul 4 11:54:20 2016
@@ -542,7 +542,7 @@ public class ToCSV {
csvLine.add("");
}
else {
- if(cell.getCellType() != CellType.FORMULA) {
+ if(cell.getCellTypeEnum() != CellType.FORMULA) {
csvLine.add(this.formatter.formatCellValue(cell));
}
else {
Modified: poi/trunk/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java Mon Jul 4 11:54:20 2016
@@ -336,9 +336,9 @@ public class ToHtml {
}
private static CellType ultimateCellType(Cell c) {
- CellType type = c.getCellType();
+ CellType type = c.getCellTypeEnum();
if (type == CellType.FORMULA)
- type = c.getCachedFormulaResultType();
+ type = c.getCachedFormulaResultTypeEnum();
return type;
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java Mon Jul 4 11:54:20 2016
@@ -321,7 +321,7 @@ public class ExcelExtractor extends POIO
// Only output if requested
outputContents = _includeBlankCells;
} else {
- switch(cell.getCellType()) {
+ switch(cell.getCellTypeEnum()) {
case STRING:
text.append(cell.getRichStringCellValue().getString());
break;
@@ -338,7 +338,7 @@ public class ExcelExtractor extends POIO
if(!_shouldEvaluateFormulas) {
text.append(cell.getCellFormula());
} else {
- switch(cell.getCachedFormulaResultType()) {
+ switch(cell.getCachedFormulaResultTypeEnum()) {
case STRING:
HSSFRichTextString str = cell.getRichStringCellValue();
if(str != null && str.length() > 0) {
@@ -359,13 +359,13 @@ public class ExcelExtractor extends POIO
text.append(ErrorEval.getText(cell.getErrorCellValue()));
break;
default:
- throw new IllegalStateException("Unexpected cell cached formula result type: " + cell.getCachedFormulaResultType());
+ throw new IllegalStateException("Unexpected cell cached formula result type: " + cell.getCachedFormulaResultTypeEnum());
}
}
break;
default:
- throw new RuntimeException("Unexpected cell type (" + cell.getCellType() + ")");
+ throw new RuntimeException("Unexpected cell type (" + cell.getCellTypeEnum() + ")");
}
// Output the comment, if requested and exists
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java Mon Jul 4 11:54:20 2016
@@ -53,6 +53,7 @@ import org.apache.poi.ss.util.CellAddres
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.ss.util.NumberToTextConverter;
+import org.apache.poi.util.Internal;
import org.apache.poi.util.LocaleUtil;
/**
@@ -442,9 +443,23 @@ public class HSSFCell implements Cell {
/**
* get the cells type (numeric, formula or string)
+ *
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ */
+ @Override
+ public int getCellType()
+ {
+ return getCellTypeEnum().getCode();
+ }
+
+ /**
+ * get the cells type (numeric, formula or string)
+ * @deprecated POI 3.15 beta 3
*/
+ @Internal
@Override
- public CellType getCellType()
+ public CellType getCellTypeEnum()
{
return _cellType;
}
@@ -995,7 +1010,7 @@ public class HSSFCell implements Cell {
* Errors are displayed as #ERR<errIdx>
*/
public String toString() {
- switch (getCellType()) {
+ switch (getCellTypeEnum()) {
case BLANK:
return "";
case BOOLEAN:
@@ -1015,7 +1030,7 @@ public class HSSFCell implements Cell {
case STRING:
return getStringCellValue();
default:
- return "Unknown Cell Type: " + getCellType();
+ return "Unknown Cell Type: " + getCellTypeEnum();
}
}
@@ -1130,11 +1145,29 @@ public class HSSFCell implements Cell {
/**
* Only valid for formula cells
+ *
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
+ * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
+ * on the cached value of the formula
+ */
+ @Override
+ public int getCachedFormulaResultType() {
+ return getCachedFormulaResultTypeEnum().getCode();
+ }
+
+ /**
+ * Only valid for formula cells
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
* on the cached value of the formula
+ * @deprecated POI 3.15 beta 3
*/
- public CellType getCachedFormulaResultType() {
+ @Internal
+ @Override
+ public CellType getCachedFormulaResultTypeEnum() {
if (_cellType != CellType.FORMULA) {
throw new IllegalStateException("Only formula cells have cached results");
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationCell.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationCell.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationCell.java Mon Jul 4 11:54:20 2016
@@ -20,6 +20,7 @@ package org.apache.poi.hssf.usermodel;
import org.apache.poi.ss.formula.EvaluationCell;
import org.apache.poi.ss.formula.EvaluationSheet;
import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.util.Internal;
/**
* HSSF wrapper for a cell under evaluation
*/
@@ -49,10 +50,22 @@ final class HSSFEvaluationCell implement
public boolean getBooleanCellValue() {
return _cell.getBooleanCellValue();
}
+ /**
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return cell type
+ */
@Override
- public CellType getCellType() {
+ public int getCellType() {
return _cell.getCellType();
}
+ /** @deprecated POI 3.15 beta 3 */
+ @Internal
+ @Override
+ public CellType getCellTypeEnum() {
+ return _cell.getCellTypeEnum();
+ }
@Override
public int getColumnIndex() {
return _cell.getColumnIndex();
@@ -76,9 +89,21 @@ final class HSSFEvaluationCell implement
@Override
public String getStringCellValue() {
return _cell.getRichStringCellValue().getString();
- }
+ }
+ /**
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return cell type of cached formula result
+ */
+ @Override
+ public int getCachedFormulaResultType() {
+ return _cell.getCachedFormulaResultType();
+ }
+ /** @deprecated POI 3.15 beta 3 */
+ @Internal
@Override
- public CellType getCachedFormulaResultType() {
- return _cell.getCachedFormulaResultType();
+ public CellType getCachedFormulaResultTypeEnum() {
+ return _cell.getCachedFormulaResultTypeEnum();
}
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java Mon Jul 4 11:54:20 2016
@@ -177,7 +177,7 @@ public class HSSFFormulaEvaluator implem
return null;
}
- switch (cell.getCellType()) {
+ switch (cell.getCellTypeEnum()) {
case BOOLEAN:
return CellValue.valueOf(cell.getBooleanCellValue());
case ERROR:
@@ -191,7 +191,7 @@ public class HSSFFormulaEvaluator implem
case BLANK:
return null;
default:
- throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
+ throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")");
}
}
@@ -214,7 +214,7 @@ public class HSSFFormulaEvaluator implem
*/
@Override
public CellType evaluateFormulaCell(Cell cell) {
- if (cell == null || cell.getCellType() != CellType.FORMULA) {
+ if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
return CellType._UNINITIALIZED;
}
CellValue cv = evaluateFormulaCellValue(cell);
@@ -244,7 +244,7 @@ public class HSSFFormulaEvaluator implem
return null;
}
HSSFCell result = (HSSFCell) cell;
- if (cell.getCellType() == CellType.FORMULA) {
+ if (cell.getCellTypeEnum() == CellType.FORMULA) {
CellValue cv = evaluateFormulaCellValue(cell);
setCellValue(cell, cv);
setCellType(cell, cv); // cell will no longer be a formula cell
@@ -330,7 +330,7 @@ public class HSSFFormulaEvaluator implem
for(Row r : sheet) {
for (Cell c : r) {
- if (c.getCellType() == CellType.FORMULA) {
+ if (c.getCellTypeEnum() == CellType.FORMULA) {
evaluator.evaluateFormulaCell(c);
}
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java Mon Jul 4 11:54:20 2016
@@ -142,7 +142,7 @@ public class HSSFOptimiser {
HSSFSheet s = workbook.getSheetAt(sheetNum);
for (Row row : s) {
for (Cell cell : row) {
- if(cell.getCellType() == CellType.STRING) {
+ if(cell.getCellTypeEnum() == CellType.STRING) {
HSSFRichTextString rtr = (HSSFRichTextString)cell.getRichStringCellValue();
UnicodeString u = rtr.getRawUnicodeString();
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java Mon Jul 4 11:54:20 2016
@@ -388,7 +388,7 @@ public final class HSSFRow implements Ro
case RETURN_NULL_AND_BLANK:
return cell;
case RETURN_BLANK_AS_NULL:
- boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK);
+ boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK);
return (isBlank) ? null : cell;
case CREATE_NULL_AS_BLANK:
return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;
Modified: poi/trunk/src/java/org/apache/poi/ss/format/CellFormat.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/format/CellFormat.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/format/CellFormat.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/format/CellFormat.java Mon Jul 4 11:54:20 2016
@@ -411,17 +411,17 @@ public class CellFormat {
/**
* Returns the ultimate cell type, following the results of formulas. If
* the cell is a {@link CellType#FORMULA}, this returns the result of
- * {@link Cell#getCachedFormulaResultType()}. Otherwise this returns the
- * result of {@link Cell#getCellType()}.
+ * {@link Cell#getCachedFormulaResultTypeEnum()}. Otherwise this returns the
+ * result of {@link Cell#getCellTypeEnum()}.
*
* @param cell The cell.
*
* @return The ultimate type of this cell.
*/
public static CellType ultimateType(Cell cell) {
- CellType type = cell.getCellType();
+ CellType type = cell.getCellTypeEnum();
if (type == CellType.FORMULA)
- return cell.getCachedFormulaResultType();
+ return cell.getCachedFormulaResultTypeEnum();
else
return type;
}
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationCache.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationCache.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationCache.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationCache.java Mon Jul 4 11:54:20 2016
@@ -56,7 +56,7 @@ final class EvaluationCache {
Loc loc = new Loc(bookIndex, sheetIndex, rowIndex, columnIndex);
PlainValueCellCacheEntry pcce = _plainCellCache.get(loc);
- if (cell.getCellType() == CellType.FORMULA) {
+ if (cell.getCellTypeEnum() == CellType.FORMULA) {
if (fcce == null) {
fcce = new FormulaCellCacheEntry();
if (pcce == null) {
@@ -197,7 +197,7 @@ final class EvaluationCache {
}
public void notifyDeleteCell(int bookIndex, int sheetIndex, EvaluationCell cell) {
- if (cell.getCellType() == CellType.FORMULA) {
+ if (cell.getCellTypeEnum() == CellType.FORMULA) {
FormulaCellCacheEntry fcce = _formulaCellCache.remove(cell);
if (fcce == null) {
// formula cell has not been evaluated yet
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationCell.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationCell.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationCell.java Mon Jul 4 11:54:20 2016
@@ -30,19 +30,35 @@ import org.apache.poi.ss.usermodel.CellT
public interface EvaluationCell {
/**
* @return an Object that identifies the underlying cell,
- * suitable for use as a key in a {@link java.util.HashMap}
+ * suitable for use as a key in a {@link java.util.HashMap}
*/
Object getIdentityKey();
EvaluationSheet getSheet();
int getRowIndex();
int getColumnIndex();
- CellType getCellType();
+ /**
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return cell type
+ */
+ int getCellType();
+ /** @deprecated POI 3.15 beta 3 */
+ CellType getCellTypeEnum();
double getNumericCellValue();
String getStringCellValue();
boolean getBooleanCellValue();
int getErrorCellValue();
-
- CellType getCachedFormulaResultType();
+
+ /**
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return cell type of cached formula result
+ */
+ int getCachedFormulaResultType();
+ /** @deprecated POI 3.15 beta 3 */
+ CellType getCachedFormulaResultTypeEnum();
}
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java Mon Jul 4 11:54:20 2016
@@ -62,7 +62,7 @@ final class SheetRefEvaluator {
public boolean isSubTotal(int rowIndex, int columnIndex){
boolean subtotal = false;
EvaluationCell cell = getSheet().getCell(rowIndex, columnIndex);
- if(cell != null && cell.getCellType() == CellType.FORMULA){
+ if(cell != null && cell.getCellTypeEnum() == CellType.FORMULA){
EvaluationWorkbook wb = _bookEvaluator.getWorkbook();
for(Ptg ptg : wb.getFormulaTokens(cell)){
if(ptg instanceof FuncVarPtg){
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java Mon Jul 4 11:54:20 2016
@@ -276,7 +276,7 @@ public final class WorkbookEvaluator {
// avoid tracking dependencies to cells that have constant definition
boolean shouldCellDependencyBeRecorded = _stabilityClassifier == null ? true
: !_stabilityClassifier.isCellFinal(sheetIndex, rowIndex, columnIndex);
- if (srcCell == null || srcCell.getCellType() != CellType.FORMULA) {
+ if (srcCell == null || srcCell.getCellTypeEnum() != CellType.FORMULA) {
ValueEval result = getValueFromNonFormulaCell(srcCell);
if (shouldCellDependencyBeRecorded) {
tracker.acceptPlainValueDependency(_workbookIx, sheetIndex, rowIndex, columnIndex, result);
@@ -314,7 +314,7 @@ public final class WorkbookEvaluator {
} catch (RuntimeException re) {
if (re.getCause() instanceof WorkbookNotFoundException && _ignoreMissingWorkbooks) {
logInfo(re.getCause().getMessage() + " - Continuing with cached value!");
- switch(srcCell.getCachedFormulaResultType()) {
+ switch(srcCell.getCachedFormulaResultTypeEnum()) {
case NUMERIC:
result = new NumberEval(srcCell.getNumericCellValue());
break;
@@ -332,7 +332,7 @@ public final class WorkbookEvaluator {
break;
case FORMULA:
default:
- throw new RuntimeException("Unexpected cell type '" + srcCell.getCellType()+"' found!");
+ throw new RuntimeException("Unexpected cell type '" + srcCell.getCellTypeEnum()+"' found!");
}
} else {
throw re;
@@ -385,7 +385,7 @@ public final class WorkbookEvaluator {
if (cell == null) {
return BlankEval.instance;
}
- CellType cellType = cell.getCellType();
+ CellType cellType = cell.getCellTypeEnum();
switch (cellType) {
case NUMERIC:
return new NumberEval(cell.getNumericCellValue());
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java Mon Jul 4 11:54:20 2016
@@ -17,16 +17,17 @@
package org.apache.poi.ss.formula.eval.forked;
+import org.apache.poi.ss.formula.EvaluationCell;
+import org.apache.poi.ss.formula.EvaluationSheet;
import org.apache.poi.ss.formula.eval.BlankEval;
import org.apache.poi.ss.formula.eval.BoolEval;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.ValueEval;
-import org.apache.poi.ss.formula.EvaluationCell;
-import org.apache.poi.ss.formula.EvaluationSheet;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.util.Internal;
/**
* Represents a cell being used for forked evaluation that has had a value set different from the
@@ -52,6 +53,7 @@ final class ForkedEvaluationCell impleme
setValue(BlankEval.instance); // followed by a proper call to setValue()
}
+ @Override
public Object getIdentityKey() {
return _masterCell.getIdentityKey();
}
@@ -101,36 +103,69 @@ final class ForkedEvaluationCell impleme
throw new RuntimeException("Wrong data type (" + _cellType + ")");
}
}
- public CellType getCellType() {
+ /**
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return cell type
+ */
+ @Override
+ public int getCellType() {
+ return _cellType.getCode();
+ }
+ /** @deprecated POI 3.15 beta 3 */
+ @Internal
+ @Override
+ public CellType getCellTypeEnum() {
return _cellType;
}
+ @Override
public boolean getBooleanCellValue() {
checkCellType(CellType.BOOLEAN);
return _booleanValue;
}
+ @Override
public int getErrorCellValue() {
checkCellType(CellType.ERROR);
return _errorValue;
}
+ @Override
public double getNumericCellValue() {
checkCellType(CellType.NUMERIC);
return _numberValue;
}
+ @Override
public String getStringCellValue() {
checkCellType(CellType.STRING);
return _stringValue;
}
+ @Override
public EvaluationSheet getSheet() {
return _sheet;
}
+ @Override
public int getRowIndex() {
return _masterCell.getRowIndex();
}
+ @Override
public int getColumnIndex() {
return _masterCell.getColumnIndex();
}
- public CellType getCachedFormulaResultType() {
- return _masterCell.getCachedFormulaResultType();
- }
+ /**
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return cell type of cached formula result
+ */
+ @Override
+ public int getCachedFormulaResultType() {
+ return _masterCell.getCachedFormulaResultType();
+ }
+ /** @deprecated POI 3.15 beta 3. */
+ @Internal
+ @Override
+ public CellType getCachedFormulaResultTypeEnum() {
+ return _masterCell.getCachedFormulaResultTypeEnum();
+ }
}
Modified: poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluator.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluator.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluator.java Mon Jul 4 11:54:20 2016
@@ -112,7 +112,7 @@ public final class ForkedEvaluator {
public ValueEval evaluate(String sheetName, int rowIndex, int columnIndex) {
EvaluationCell cell = _sewb.getEvaluationCell(sheetName, rowIndex, columnIndex);
- switch (cell.getCellType()) {
+ switch (cell.getCellTypeEnum()) {
case BOOLEAN:
return BoolEval.valueOf(cell.getBooleanCellValue());
case ERROR:
@@ -126,7 +126,7 @@ public final class ForkedEvaluator {
case BLANK:
return null;
default:
- throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
+ throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")");
}
}
/**
Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java Mon Jul 4 11:54:20 2016
@@ -23,6 +23,7 @@ import java.util.Date;
import org.apache.poi.ss.formula.FormulaParseException;
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.util.Internal;
/**
* High level representation of a cell in a row of a spreadsheet.
@@ -153,18 +154,44 @@ public interface Cell {
/**
* Return the cell type.
+ *
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
*
* @return the cell type
*/
- CellType getCellType();
+ int getCellType();
+
+ /**
+ * Return the cell type.
+ *
+ * @return the cell type
+ * @deprecated POI 3.15 beta 3
+ */
+ @Internal
+ CellType getCellTypeEnum();
+
+ /**
+ * Only valid for formula cells
+ *
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
+ * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
+ * on the cached value of the formula
+ */
+ int getCachedFormulaResultType();
/**
* Only valid for formula cells
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
* on the cached value of the formula
+ * @deprecated POI 3.15 beta 3
*/
- CellType getCachedFormulaResultType();
+ @Internal
+ CellType getCachedFormulaResultTypeEnum();
/**
* Set a numeric value for the cell
@@ -248,7 +275,7 @@ public interface Cell {
* Return a formula for the cell, for example, <code>SUM(C4:E4)</code>
*
* @return a formula for the cell
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not {@link CellType#FORMULA}
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not {@link CellType#FORMULA}
*/
String getCellFormula();
@@ -259,7 +286,7 @@ public interface Cell {
* For formulas or error cells we return the precalculated value;
* </p>
* @return the value of the cell as a number
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING}
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING}
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
* @see DataFormatter for turning this number into a string similar to that which Excel would render this number as.
*/
@@ -271,7 +298,7 @@ public interface Cell {
* For strings we throw an exception. For blank cells we return a null.
* </p>
* @return the value of the cell as a date
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING}
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING}
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
* @see DataFormatter for formatting this date into a string similar to how excel does.
*/
@@ -323,7 +350,7 @@ public interface Cell {
* For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
* </p>
* @return the value of the cell as a boolean
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()}
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()}
* is not {@link CellType#BOOLEAN}, {@link CellType#BLANK} or {@link CellType#FORMULA}
*/
boolean getBooleanCellValue();
@@ -336,7 +363,7 @@ public interface Cell {
* </p>
*
* @return the value of the cell as an error code
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't {@link CellType#ERROR}
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType#ERROR}
* @see FormulaError for error codes
*/
byte getErrorCellValue();
Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java Mon Jul 4 11:54:20 2016
@@ -879,7 +879,7 @@ public class DataFormatter implements Ob
return "";
}
- CellType cellType = cell.getCellType();
+ CellType cellType = cell.getCellTypeEnum();
if (cellType == CellType.FORMULA) {
if (evaluator == null) {
return cell.getCellFormula();
Modified: poi/trunk/src/java/org/apache/poi/ss/util/SheetUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/SheetUtil.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/SheetUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/SheetUtil.java Mon Jul 4 11:54:20 2016
@@ -81,7 +81,7 @@ public class SheetUtil {
public void evaluateAll() {}
public CellType evaluateFormulaCell(Cell cell) {
- return cell.getCachedFormulaResultType();
+ return cell.getCachedFormulaResultTypeEnum();
}
};
@@ -120,11 +120,11 @@ public class SheetUtil {
}
CellStyle style = cell.getCellStyle();
- CellType cellType = cell.getCellType();
+ CellType cellType = cell.getCellTypeEnum();
// for formula cells we compute the cell width for the cached formula result
if (cellType == CellType.FORMULA)
- cellType = cell.getCachedFormulaResultType();
+ cellType = cell.getCachedFormulaResultTypeEnum();
Font font = wb.getFontAt(style.getFontIndex());
Modified: poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java Mon Jul 4 11:54:20 2016
@@ -101,7 +101,7 @@ public class CellWalk {
}
private boolean isEmpty(Cell cell) {
- return (cell.getCellType() == CellType.BLANK);
+ return (cell.getCellTypeEnum() == CellType.BLANK);
}
/**
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java Mon Jul 4 11:54:20 2016
@@ -162,19 +162,19 @@ public class XSSFExcelExtractor extends
Cell cell = ri.next();
// Is it a formula one?
- if(cell.getCellType() == CellType.FORMULA) {
+ if(cell.getCellTypeEnum() == CellType.FORMULA) {
if (formulasNotResults) {
String contents = cell.getCellFormula();
checkMaxTextSize(text, contents);
text.append(contents);
} else {
- if (cell.getCachedFormulaResultType() == CellType.STRING) {
+ if (cell.getCachedFormulaResultTypeEnum() == CellType.STRING) {
handleStringCell(text, cell);
} else {
handleNonStringCell(text, cell, formatter);
}
}
- } else if(cell.getCellType() == CellType.STRING) {
+ } else if(cell.getCellTypeEnum() == CellType.STRING) {
handleStringCell(text, cell);
} else {
handleNonStringCell(text, cell, formatter);
@@ -236,9 +236,9 @@ public class XSSFExcelExtractor extends
}
private void handleNonStringCell(StringBuffer text, Cell cell, DataFormatter formatter) {
- CellType type = cell.getCellType();
+ CellType type = cell.getCellTypeEnum();
if (type == CellType.FORMULA) {
- type = cell.getCachedFormulaResultType();
+ type = cell.getCachedFormulaResultTypeEnum();
}
if (type == CellType.NUMERIC) {
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java Mon Jul 4 11:54:20 2016
@@ -278,13 +278,13 @@ public class XSSFExportToXml implements
private void mapCellOnNode(XSSFCell cell, Node node, STXmlDataType.Enum outputDataType) {
String value ="";
- switch (cell.getCellType()) {
+ switch (cell.getCellTypeEnum()) {
case STRING: value = cell.getStringCellValue(); break;
case BOOLEAN: value += cell.getBooleanCellValue(); break;
case ERROR: value = cell.getErrorCellString(); break;
case FORMULA:
- if (cell.getCachedFormulaResultType() == CellType.STRING) {
+ if (cell.getCachedFormulaResultTypeEnum() == CellType.STRING) {
value = cell.getStringCellValue();
} else {
if (DateUtil.isCellDateFormatted(cell)) {
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java Mon Jul 4 11:54:20 2016
@@ -38,6 +38,7 @@ import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.util.Internal;
import org.apache.poi.util.LocaleUtil;
import org.apache.poi.util.NotImplemented;
import org.apache.poi.util.POILogFactory;
@@ -150,7 +151,20 @@ public class SXSSFCell implements Cell {
* @return the cell type
*/
@Override
- public CellType getCellType()
+ public int getCellType()
+ {
+ return getCellTypeEnum().getCode();
+ }
+
+ /**
+ * Return the cell type.
+ *
+ * @return the cell type
+ * @deprecated POI 3.15 beta 3
+ */
+ @Internal
+ @Override
+ public CellType getCellTypeEnum()
{
return _value.getType();
}
@@ -162,7 +176,21 @@ public class SXSSFCell implements Cell {
* on the cached value of the formula
*/
@Override
- public CellType getCachedFormulaResultType()
+ public int getCachedFormulaResultType()
+ {
+ return getCachedFormulaResultTypeEnum().getCode();
+ }
+
+ /**
+ * Only valid for formula cells
+ * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
+ * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
+ * on the cached value of the formula
+ * @deprecated POI 3.15 beta 3.
+ */
+ @Internal
+ @Override
+ public CellType getCachedFormulaResultTypeEnum()
{
if (_value.getType() != CellType.FORMULA) {
throw new IllegalStateException("Only formula cells have cached results");
@@ -330,7 +358,7 @@ public class SXSSFCell implements Cell {
* Return a formula for the cell, for example, <code>SUM(C4:E4)</code>
*
* @return a formula for the cell
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not CellType.FORMULA
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not CellType.FORMULA
*/
@Override
public String getCellFormula()
@@ -347,14 +375,14 @@ public class SXSSFCell implements Cell {
* For formulas or error cells we return the precalculated value;
* </p>
* @return the value of the cell as a number
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is CellType.STRING
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is CellType.STRING
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
* @see org.apache.poi.ss.usermodel.DataFormatter for turning this number into a string similar to that which Excel would render this number as.
*/
@Override
public double getNumericCellValue()
{
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
switch(cellType)
{
case BLANK:
@@ -379,14 +407,14 @@ public class SXSSFCell implements Cell {
* For strings we throw an exception. For blank cells we return a null.
* </p>
* @return the value of the cell as a date
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is CellType.STRING
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is CellType.STRING
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
* @see org.apache.poi.ss.usermodel.DataFormatter for formatting this date into a string similar to how excel does.
*/
@Override
public Date getDateCellValue()
{
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
if (cellType == CellType.BLANK)
{
return null;
@@ -408,8 +436,8 @@ public class SXSSFCell implements Cell {
@Override
public RichTextString getRichStringCellValue()
{
- CellType cellType = getCellType();
- if(getCellType() != CellType.STRING)
+ CellType cellType = getCellTypeEnum();
+ if(getCellTypeEnum() != CellType.STRING)
throw typeMismatch(CellType.STRING, cellType, false);
StringValue sval = (StringValue)_value;
@@ -433,7 +461,7 @@ public class SXSSFCell implements Cell {
@Override
public String getStringCellValue()
{
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
switch(cellType)
{
case BLANK:
@@ -499,13 +527,13 @@ public class SXSSFCell implements Cell {
* For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
* </p>
* @return the value of the cell as a boolean
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()}
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()}
* is not CellType.BOOLEAN, CellType.BLANK or CellType.FORMULA
*/
@Override
public boolean getBooleanCellValue()
{
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
switch(cellType)
{
case BLANK:
@@ -534,13 +562,13 @@ public class SXSSFCell implements Cell {
* </p>
*
* @return the value of the cell as an error code
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't CellType.ERROR
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't CellType.ERROR
* @see org.apache.poi.ss.usermodel.FormulaError for error codes
*/
@Override
public byte getErrorCellValue()
{
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
switch(cellType)
{
case BLANK:
@@ -714,7 +742,7 @@ public class SXSSFCell implements Cell {
*/
@Override
public String toString() {
- switch (getCellType()) {
+ switch (getCellTypeEnum()) {
case BLANK:
return "";
case BOOLEAN:
@@ -733,7 +761,7 @@ public class SXSSFCell implements Cell {
case STRING:
return getRichStringCellValue().toString();
default:
- return "Unknown Cell Type: " + getCellType();
+ return "Unknown Cell Type: " + getCellTypeEnum();
}
}
@@ -959,10 +987,10 @@ public class SXSSFCell implements Cell {
}
private boolean convertCellValueToBoolean() {
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
if (cellType == CellType.FORMULA) {
- cellType = getCachedFormulaResultType();
+ cellType = getCachedFormulaResultTypeEnum();
}
switch (cellType) {
@@ -982,7 +1010,7 @@ public class SXSSFCell implements Cell {
}
private String convertCellValueToString() {
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
return convertCellValueToString(cellType);
}
private String convertCellValueToString(CellType cellType) {
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationCell.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationCell.java Mon Jul 4 11:54:20 2016
@@ -20,6 +20,7 @@ package org.apache.poi.xssf.streaming;
import org.apache.poi.ss.formula.EvaluationCell;
import org.apache.poi.ss.formula.EvaluationSheet;
import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.util.Internal;
/**
* SXSSF wrapper for a cell under evaluation
@@ -51,10 +52,22 @@ final class SXSSFEvaluationCell implemen
public boolean getBooleanCellValue() {
return _cell.getBooleanCellValue();
}
+ /**
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return cell type
+ */
@Override
- public CellType getCellType() {
+ public int getCellType() {
return _cell.getCellType();
}
+ /** @deprecated POI 3.15 beta 3 */
+ @Internal
+ @Override
+ public CellType getCellTypeEnum() {
+ return _cell.getCellTypeEnum();
+ }
@Override
public int getColumnIndex() {
return _cell.getColumnIndex();
@@ -78,9 +91,21 @@ final class SXSSFEvaluationCell implemen
@Override
public String getStringCellValue() {
return _cell.getRichStringCellValue().getString();
- }
+ }
+ /**
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return cell type of cached formula result
+ */
+ @Override
+ public int getCachedFormulaResultType() {
+ return _cell.getCachedFormulaResultType();
+ }
+ /** @deprecated POI 3.15 beta 3 */
+ @Internal
@Override
- public CellType getCachedFormulaResultType() {
- return _cell.getCachedFormulaResultType();
+ public CellType getCachedFormulaResultTypeEnum() {
+ return _cell.getCachedFormulaResultTypeEnum();
}
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java Mon Jul 4 11:54:20 2016
@@ -121,7 +121,7 @@ public final class SXSSFFormulaEvaluator
// Evaluate what we have
for (Row r : sheet) {
for (Cell c : r) {
- if (c.getCellType() == CellType.FORMULA) {
+ if (c.getCellTypeEnum() == CellType.FORMULA) {
eval.evaluateFormulaCell(c);
}
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java Mon Jul 4 11:54:20 2016
@@ -268,7 +268,7 @@ public class SXSSFRow implements Row, Co
case RETURN_NULL_AND_BLANK:
return cell;
case RETURN_BLANK_AS_NULL:
- boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK);
+ boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK);
return (isBlank) ? null : cell;
case CREATE_NULL_AS_BLANK:
return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java Mon Jul 4 11:54:20 2016
@@ -202,7 +202,7 @@ public class SheetDataWriter {
// APIs
_out.write(" s=\"" + (cellStyle.getIndex() & 0xffff) + "\"");
}
- CellType cellType = cell.getCellType();
+ CellType cellType = cell.getCellTypeEnum();
switch (cellType) {
case BLANK: {
_out.write(">");
@@ -213,7 +213,7 @@ public class SheetDataWriter {
_out.write("<f>");
outputQuotedString(cell.getCellFormula());
_out.write("</f>");
- switch (cell.getCachedFormulaResultType()) {
+ switch (cell.getCachedFormulaResultTypeEnum()) {
case NUMERIC:
double nval = cell.getNumericCellValue();
if (!Double.isNaN(nval)) {
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java Mon Jul 4 11:54:20 2016
@@ -75,7 +75,7 @@ public abstract class BaseXSSFFormulaEva
return null;
}
- switch (cell.getCellType()) {
+ switch (cell.getCellTypeEnum()) {
case BOOLEAN:
return CellValue.valueOf(cell.getBooleanCellValue());
case ERROR:
@@ -89,7 +89,7 @@ public abstract class BaseXSSFFormulaEva
case BLANK:
return null;
default:
- throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
+ throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")");
}
}
@@ -113,7 +113,7 @@ public abstract class BaseXSSFFormulaEva
* @return The type of the formula result (the cell's type remains as CellType.FORMULA however)
*/
public CellType evaluateFormulaCell(Cell cell) {
- if (cell == null || cell.getCellType() != CellType.FORMULA) {
+ if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
return CellType._UNINITIALIZED;
}
CellValue cv = evaluateFormulaCellValue(cell);
@@ -131,7 +131,7 @@ public abstract class BaseXSSFFormulaEva
*/
protected void doEvaluateInCell(Cell cell) {
if (cell == null) return;
- if (cell.getCellType() == CellType.FORMULA) {
+ if (cell.getCellTypeEnum() == CellType.FORMULA) {
CellValue cv = evaluateFormulaCellValue(cell);
setCellType(cell, cv); // cell will no longer be a formula cell
setCellValue(cell, cv);
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java Mon Jul 4 11:54:20 2016
@@ -138,11 +138,11 @@ public final class XSSFCell implements C
// Copy cell value (cell type is updated implicitly)
if (policy.isCopyCellValue()) {
if (srcCell != null) {
- CellType copyCellType = srcCell.getCellType();
+ CellType copyCellType = srcCell.getCellTypeEnum();
if (copyCellType == CellType.FORMULA && !policy.isCopyCellFormula()) {
// Copy formula result as value
// FIXME: Cached value may be stale
- copyCellType = srcCell.getCachedFormulaResultType();
+ copyCellType = srcCell.getCachedFormulaResultTypeEnum();
}
switch (copyCellType) {
case NUMERIC:
@@ -171,7 +171,7 @@ public final class XSSFCell implements C
break;
default:
- throw new IllegalArgumentException("Invalid cell type " + srcCell.getCellType());
+ throw new IllegalArgumentException("Invalid cell type " + srcCell.getCellTypeEnum());
}
} else { //srcCell is null
setBlank();
@@ -249,12 +249,12 @@ public final class XSSFCell implements C
* For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
* </p>
* @return the value of the cell as a boolean
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()}
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()}
* is not {@link CellType#BOOLEAN}, {@link CellType#BLANK} or {@link CellType#FORMULA}
*/
@Override
public boolean getBooleanCellValue() {
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
switch(cellType) {
case BLANK:
return false;
@@ -288,13 +288,13 @@ public final class XSSFCell implements C
* For formulas or error cells we return the precalculated value;
* </p>
* @return the value of the cell as a number
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING}
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING}
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
* @see DataFormatter for turning this number into a string similar to that which Excel would render this number as.
*/
@Override
public double getNumericCellValue() {
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
switch(cellType) {
case BLANK:
return 0.0;
@@ -366,7 +366,7 @@ public final class XSSFCell implements C
*/
@Override
public XSSFRichTextString getRichStringCellValue() {
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
XSSFRichTextString rt;
switch (cellType) {
case BLANK:
@@ -445,7 +445,7 @@ public final class XSSFCell implements C
throw new IllegalArgumentException("The maximum length of cell contents (text) is 32,767 characters");
}
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
switch (cellType){
case FORMULA:
_cell.setV(str.getString());
@@ -470,7 +470,7 @@ public final class XSSFCell implements C
* Return a formula for the cell, for example, <code>SUM(C4:E4)</code>
*
* @return a formula for the cell
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not {@link CellType#FORMULA}
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not {@link CellType#FORMULA}
*/
@Override
public String getCellFormula() {
@@ -483,10 +483,10 @@ public final class XSSFCell implements C
*
* @param fpb evaluation workbook for reuse, if available, or null to create a new one as needed
* @return a formula for the cell
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not {@link CellType#FORMULA}
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not {@link CellType#FORMULA}
*/
protected String getCellFormula(XSSFEvaluationWorkbook fpb) {
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
if(cellType != CellType.FORMULA) throw typeMismatch(CellType.FORMULA, cellType, false);
CTCellFormula f = _cell.getF();
@@ -660,14 +660,29 @@ public final class XSSFCell implements C
}
return false;
}
+
+ /**
+ * Return the cell type.
+ *
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return the cell type
+ */
+ @Override
+ public int getCellType() {
+ return getCellTypeEnum().getCode();
+ }
/**
* Return the cell type.
*
* @return the cell type
+ * @deprecated POI 3.15 beta 3
*/
+ @Internal
@Override
- public CellType getCellType() {
+ public CellType getCellTypeEnum() {
if (isFormulaCell()) return CellType.FORMULA;
return getBaseCellType(true);
@@ -675,12 +690,29 @@ public final class XSSFCell implements C
/**
* Only valid for formula cells
+ *
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
+ * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
+ * on the cached value of the formula
+ */
+ @Override
+ public int getCachedFormulaResultType() {
+ return getCachedFormulaResultTypeEnum().getCode();
+ }
+
+ /**
+ * Only valid for formula cells
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
* on the cached value of the formula
+ * @deprecated POI 3.15 beta 3
*/
+ @Internal
@Override
- public CellType getCachedFormulaResultType() {
+ public CellType getCachedFormulaResultTypeEnum() {
if (! isFormulaCell()) {
throw new IllegalStateException("Only formula cells have cached results");
}
@@ -722,13 +754,13 @@ public final class XSSFCell implements C
* For strings we throw an exception. For blank cells we return a null.
* </p>
* @return the value of the cell as a date
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING}
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING}
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
* @see DataFormatter for formatting this date into a string similar to how excel does.
*/
@Override
public Date getDateCellValue() {
- if (getCellType() == CellType.BLANK) {
+ if (getCellTypeEnum() == CellType.BLANK) {
return null;
}
@@ -787,7 +819,7 @@ public final class XSSFCell implements C
* Returns the error message, such as #VALUE!
*
* @return the error message such as #VALUE!
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't {@link CellType#ERROR}
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType#ERROR}
* @see FormulaError
*/
public String getErrorCellString() {
@@ -804,7 +836,7 @@ public final class XSSFCell implements C
* </p>
*
* @return the value of the cell as an error code
- * @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't {@link CellType #ERROR}
+ * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType #ERROR}
* @see FormulaError
*/
@Override
@@ -899,7 +931,7 @@ public final class XSSFCell implements C
*/
@Override
public void setCellType(CellType cellType) {
- CellType prevType = getCellType();
+ CellType prevType = getCellTypeEnum();
if(isPartOfArrayFormulaGroup()){
notifyArrayFormulaChanging();
@@ -962,7 +994,7 @@ public final class XSSFCell implements C
*/
@Override
public String toString() {
- switch (getCellType()) {
+ switch (getCellTypeEnum()) {
case NUMERIC:
if (DateUtil.isCellDateFormatted(this)) {
DateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", LocaleUtil.getUserLocale());
@@ -981,7 +1013,7 @@ public final class XSSFCell implements C
case ERROR:
return ErrorEval.getText(getErrorCellValue());
default:
- return "Unknown Cell Type: " + getCellType();
+ return "Unknown Cell Type: " + getCellTypeEnum();
}
}
@@ -1133,7 +1165,7 @@ public final class XSSFCell implements C
* TODO - perhaps a method like setCellTypeAndValue(int, Object) should be introduced to avoid this
*/
private boolean convertCellValueToBoolean() {
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
if (cellType == CellType.FORMULA) {
cellType = getBaseCellType(false);
@@ -1161,7 +1193,7 @@ public final class XSSFCell implements C
}
private String convertCellValueToString() {
- CellType cellType = getCellType();
+ CellType cellType = getCellTypeEnum();
switch (cellType) {
case BLANK:
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java Mon Jul 4 11:54:20 2016
@@ -20,6 +20,7 @@ package org.apache.poi.xssf.usermodel;
import org.apache.poi.ss.formula.EvaluationCell;
import org.apache.poi.ss.formula.EvaluationSheet;
import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.util.Internal;
/**
* XSSF wrapper for a cell under evaluation
@@ -52,10 +53,22 @@ final class XSSFEvaluationCell implement
public boolean getBooleanCellValue() {
return _cell.getBooleanCellValue();
}
+/**
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return cell type
+ */
@Override
- public CellType getCellType() {
+ public int getCellType() {
return _cell.getCellType();
}
+ /** @deprecated POI 3.15 beta 3 */
+ @Internal
+ @Override
+ public CellType getCellTypeEnum() {
+ return _cell.getCellTypeEnum();
+ }
@Override
public int getColumnIndex() {
return _cell.getColumnIndex();
@@ -79,9 +92,21 @@ final class XSSFEvaluationCell implement
@Override
public String getStringCellValue() {
return _cell.getRichStringCellValue().getString();
- }
+ }
+ /**
+ * Will return {@link CellType} in a future version of POI.
+ * For forwards compatibility, do not hard-code cell type literals in your code.
+ *
+ * @return cell type of cached formula result
+ */
+ @Override
+ public int getCachedFormulaResultType() {
+ return _cell.getCachedFormulaResultType();
+ }
+ /** @deprecated POI 3.15 beta 3 */
+ @Internal
@Override
- public CellType getCachedFormulaResultType() {
- return _cell.getCachedFormulaResultType();
+ public CellType getCachedFormulaResultTypeEnum() {
+ return _cell.getCachedFormulaResultTypeEnum();
}
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java Mon Jul 4 11:54:20 2016
@@ -276,7 +276,7 @@ public class XSSFRow implements Row, Com
case RETURN_NULL_AND_BLANK:
return cell;
case RETURN_BLANK_AS_NULL:
- boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK);
+ boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK);
return (isBlank) ? null : cell;
case CREATE_NULL_AS_BLANK:
return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;
@@ -496,7 +496,7 @@ public class XSSFRow implements Row, Com
if(xcell.isPartOfArrayFormulaGroup()) {
xcell.notifyArrayFormulaChanging();
}
- if(cell.getCellType() == CellType.FORMULA) {
+ if(cell.getCellTypeEnum() == CellType.FORMULA) {
_sheet.getWorkbook().onDeleteFormula(xcell);
}
// Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory
@@ -636,7 +636,7 @@ public class XSSFRow implements Row, Com
else {
for (final Cell c : srcRow){
final XSSFCell srcCell = (XSSFCell)c;
- final XSSFCell destCell = createCell(srcCell.getColumnIndex(), srcCell.getCellType());
+ final XSSFCell destCell = createCell(srcCell.getColumnIndex(), srcCell.getCellTypeEnum());
destCell.copyCellFrom(srcCell, policy);
}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java Mon Jul 4 11:54:20 2016
@@ -77,7 +77,7 @@ public final class XSSFFormulaUtils {
for (Sheet sh : _wb) {
for (Row row : sh) {
for (Cell cell : row) {
- if (cell.getCellType() == CellType.FORMULA) {
+ if (cell.getCellTypeEnum() == CellType.FORMULA) {
updateFormula((XSSFCell) cell, oldName, newName);
}
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java Mon Jul 4 11:54:20 2016
@@ -42,7 +42,7 @@ public final class TestCalculationChain
XSSFSheet sheet = wb.getSheet("Test");
XSSFCell cell = sheet.getRow(0).getCell(4);
- assertEquals(CellType.FORMULA, cell.getCellType());
+ assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
cell.setCellFormula(null);
//the count of items is less by one
@@ -53,9 +53,9 @@ public final class TestCalculationChain
assertEquals(10, c.getI());
assertEquals("C1", c.getR());
- assertEquals(CellType.STRING, cell.getCellType());
+ assertEquals(CellType.STRING, cell.getCellTypeEnum());
cell.setCellValue("ABC");
- assertEquals(CellType.STRING, cell.getCellType());
+ assertEquals(CellType.STRING, cell.getCellTypeEnum());
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java Mon Jul 4 11:54:20 2016
@@ -190,7 +190,7 @@ public final class TestFormulaEvaluatorO
for (short colnum=SS.COLUMN_INDEX_FIRST_TEST_VALUE; colnum < endcolnum; colnum++) {
Cell c = formulasRow.getCell(colnum);
assumeNotNull(c);
- assumeTrue(c.getCellType() == CellType.FORMULA);
+ assumeTrue(c.getCellTypeEnum() == CellType.FORMULA);
ignoredFormulaTestCase(c.getCellFormula());
CellValue actValue = evaluator.evaluate(c);
@@ -202,7 +202,7 @@ public final class TestFormulaEvaluatorO
assertNotNull(msg + " - Bad setup data expected value is null", expValue);
assertNotNull(msg + " - actual value was null", actValue);
- final CellType expectedCellType = expValue.getCellType();
+ final CellType expectedCellType = expValue.getCellTypeEnum();
switch (expectedCellType) {
case BLANK:
assertEquals(msg, CellType.BLANK, actValue.getCellType());
@@ -264,10 +264,10 @@ public final class TestFormulaEvaluatorO
logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name");
return null;
}
- if(cell.getCellType() == CellType.BLANK) {
+ if(cell.getCellTypeEnum() == CellType.BLANK) {
return null;
}
- if(cell.getCellType() == CellType.STRING) {
+ if(cell.getCellTypeEnum() == CellType.STRING) {
return cell.getRichStringCellValue().getString();
}
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java?rev=1751256&r1=1751255&r2=1751256&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java Mon Jul 4 11:54:20 2016
@@ -176,7 +176,7 @@ public final class TestMultiSheetFormula
Cell c = r.getCell(SS.COLUMN_INDEX_ACTUAL_VALUE);
assumeNotNull(c);
- assumeTrue(c.getCellType() == CellType.FORMULA);
+ assumeTrue(c.getCellTypeEnum() == CellType.FORMULA);
CellValue actValue = evaluator.evaluate(c);
@@ -185,7 +185,7 @@ public final class TestMultiSheetFormula
assertNotNull(msg + " - actual value was null", actValue);
- final CellType expectedCellType = expValue.getCellType();
+ final CellType expectedCellType = expValue.getCellTypeEnum();
switch (expectedCellType) {
case BLANK:
assertEquals(msg, CellType.BLANK, actValue.getCellType());
@@ -231,15 +231,15 @@ public final class TestMultiSheetFormula
logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name");
return null;
}
- if(cell.getCellType() == CellType.BLANK) {
+ if(cell.getCellTypeEnum() == CellType.BLANK) {
return null;
}
- if(cell.getCellType() == CellType.STRING) {
+ if(cell.getCellTypeEnum() == CellType.STRING) {
return cell.getRichStringCellValue().getString();
}
fail("Bad cell type for 'function name' column: ("
- + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
+ + cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")");
return "";
}
/**
@@ -255,15 +255,15 @@ public final class TestMultiSheetFormula
logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_TEST_NAME + ", can't figure out test name");
return null;
}
- if(cell.getCellType() == CellType.BLANK) {
+ if(cell.getCellTypeEnum() == CellType.BLANK) {
return null;
}
- if(cell.getCellType() == CellType.STRING) {
+ if(cell.getCellTypeEnum() == CellType.STRING) {
return cell.getRichStringCellValue().getString();
}
fail("Bad cell type for 'test name' column: ("
- + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
+ + cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")");
return "";
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org