Author: fanningpj
Date: Sun Mar 23 10:59:43 2025
New Revision: 1924533
URL: http://svn.apache.org/viewvc?rev=1924533&view=rev
Log:
partially revert cell toString changes
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCell.java
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCell.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCell.java?rev=1924533&r1=1924532&r2=1924533&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCell.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFCell.java
Sun Mar 23 10:59:43 2025
@@ -721,8 +721,6 @@ public class SXSSFCell extends CellBase
}
//end of interface implementation
- private static final DataFormatter DATA_FORMATTER = new DataFormatter();
-
/**
* Returns a string representation of the cell
* <p>
@@ -743,8 +741,14 @@ public class SXSSFCell extends CellBase
case FORMULA:
return getCellFormula();
case NUMERIC:
+ if (DateUtil.isCellDateFormatted(this)) {
+ DataFormatter df = new DataFormatter();
+ df.setUseCachedValuesForFormulaCells(true);
+ return df.formatCellValue(this);
+ }
+ return Double.toString(getNumericCellValue());
case STRING:
- return DATA_FORMATTER.formatCellValue(this);
+ return getRichStringCellValue().toString();
default:
return "Unknown Cell Type: " + getCellType();
}
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java?rev=1924533&r1=1924532&r2=1924533&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFCell.java
Sun Mar 23 10:59:43 2025
@@ -49,6 +49,7 @@ import org.apache.poi.ss.util.CellUtil;
import org.apache.poi.util.Beta;
import org.apache.poi.util.ExceptionUtil;
import org.apache.poi.util.Internal;
+import org.apache.poi.util.LocaleUtil;
import org.apache.poi.xssf.model.CalculationChain;
import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.xssf.model.StylesTable;
@@ -924,8 +925,6 @@ public final class XSSFCell extends Cell
}
}
- private static final DataFormatter DATA_FORMATTER = new DataFormatter();
-
/**
* Returns a string representation of the cell
* <p>
@@ -938,8 +937,14 @@ public final class XSSFCell extends Cell
public String toString() {
switch (getCellType()) {
case NUMERIC:
+ if (DateUtil.isCellDateFormatted(this)) {
+ DataFormatter df = new DataFormatter();
+ df.setUseCachedValuesForFormulaCells(true);
+ return df.formatCellValue(this);
+ }
+ return Double.toString(getNumericCellValue());
case STRING:
- return DATA_FORMATTER.formatCellValue(this);
+ return getRichStringCellValue().toString();
case FORMULA:
return getCellFormula();
case BLANK:
Modified:
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java?rev=1924533&r1=1924532&r2=1924533&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java
(original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCell.java Sun
Mar 23 10:59:43 2025
@@ -55,6 +55,7 @@ import org.apache.poi.ss.usermodel.RichT
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.LocaleUtil;
/**
* High level representation of a cell in a row of a spreadsheet.
@@ -1020,8 +1021,6 @@ public class HSSFCell extends CellBase {
_sheet.getSheet().setActiveCellCol(col);
}
- private static final DataFormatter DATA_FORMATTER = new DataFormatter();
-
/**
* Returns a string representation of the cell
*
@@ -1045,8 +1044,14 @@ public class HSSFCell extends CellBase {
case FORMULA:
return getCellFormula();
case NUMERIC:
+ if (DateUtil.isCellDateFormatted(this)) {
+ DataFormatter df = new DataFormatter();
+ df.setUseCachedValuesForFormulaCells(true);
+ return df.formatCellValue(this);
+ }
+ return Double.toString(getNumericCellValue());
case STRING:
- return DATA_FORMATTER.formatCellValue(this);
+ return getRichStringCellValue().toString();
default:
return "Unknown Cell Type: " + getCellType();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]