aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2009-05-16 17:39:31 +0000
committerNick Burch <nick@apache.org>2009-05-16 17:39:31 +0000
commit631a96b8bc38d60e97c0d4f87fac557de9ae7f12 (patch)
tree480ce9c2f8bed67489eac139c1798967d93e8cf3
parent21fae5b0d23951e2c081bb32549ca210818615d3 (diff)
downloadpoi-631a96b8bc38d60e97c0d4f87fac557de9ae7f12.tar.gz
poi-631a96b8bc38d60e97c0d4f87fac557de9ae7f12.zip
Fix bug #47154 - Handle the cell format @ as the same as General
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@775500 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/documentation/content/xdocs/changes.xml1
-rw-r--r--src/documentation/content/xdocs/status.xml1
-rwxr-xr-xsrc/java/org/apache/poi/ss/usermodel/DataFormatter.java2
-rw-r--r--src/testcases/org/apache/poi/hssf/data/47154.xlsbin0 -> 6656 bytes
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java20
5 files changed, 23 insertions, 1 deletions
diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml
index a279c64ac2..cdb6bdfe85 100644
--- a/src/documentation/content/xdocs/changes.xml
+++ b/src/documentation/content/xdocs/changes.xml
@@ -37,6 +37,7 @@
<!-- Don't forget to update status.xml too! -->
<release version="3.5-beta6" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">47154 - Handle the cell format @ as the same as General</action>
<action dev="POI-DEVELOPERS" type="fix">47048 - Fixed evaluation of defined names with the 'complex' flag set</action>
<action dev="POI-DEVELOPERS" type="fix">46953 - More tweaks to PageSettingsBlock parsing logic in Sheet constructor</action>
<action dev="POI-DEVELOPERS" type="fix">47089 - Fixed XSSFWorkbook.createSheet to properly increment sheetId</action>
diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml
index 65e7caa030..2008d00b36 100644
--- a/src/documentation/content/xdocs/status.xml
+++ b/src/documentation/content/xdocs/status.xml
@@ -34,6 +34,7 @@
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.5-beta6" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">47154 - Handle the cell format @ as the same as General</action>
<action dev="POI-DEVELOPERS" type="fix">47048 - Fixed evaluation of defined names with the 'complex' flag set</action>
<action dev="POI-DEVELOPERS" type="fix">46953 - More tweaks to PageSettingsBlock parsing logic in Sheet constructor</action>
<action dev="POI-DEVELOPERS" type="fix">47089 - Fixed XSSFWorkbook.createSheet to properly increment sheetId</action>
diff --git a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
index 378f3303ca..50e3690f7c 100755
--- a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
+++ b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
@@ -147,7 +147,7 @@ public class DataFormatter {
if (format != null) {
return format;
}
- if (formatStr.equals("General")) {
+ if (formatStr.equals("General") || formatStr.equals("@")) {
if (DataFormatter.isWholeNumber(cellValue)) {
return generalWholeNumFormat;
}
diff --git a/src/testcases/org/apache/poi/hssf/data/47154.xls b/src/testcases/org/apache/poi/hssf/data/47154.xls
new file mode 100644
index 0000000000..2840cc61b6
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/data/47154.xls
Binary files differ
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java
index e1a6e1b3ca..718d909b66 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java
@@ -21,6 +21,8 @@ import java.text.DecimalFormat;
import java.text.Format;
import java.util.Iterator;
+import org.apache.poi.hssf.HSSFTestDataSamples;
+
import junit.framework.TestCase;
/**
@@ -267,6 +269,24 @@ public final class TestHSSFDataFormatter extends TestCase {
assertTrue(formatter.formatCellValue(cell).endsWith(" USD"));
}
}
+
+ /**
+ * A format of "@" means use the general format
+ */
+ public void testGeneralAtFormat() {
+ HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("47154.xls");
+ HSSFSheet sheet = workbook.getSheetAt(0);
+ HSSFRow row = sheet.getRow(0);
+ HSSFCell cellA1 = row.getCell(0);
+
+ assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cellA1.getCellType());
+ assertEquals(2345.0, cellA1.getNumericCellValue(), 0.0001);
+ assertEquals("@", cellA1.getCellStyle().getDataFormatString());
+
+ HSSFDataFormatter f = new HSSFDataFormatter();
+
+ assertEquals("2345", f.formatCellValue(cellA1));
+ }
private static void log(String msg) {
if (false) { // successful tests should be silent