]> source.dussan.org Git - poi.git/commitdiff
bug 60025: DataFormatter should print booleans as TRUE/FALSE, not true/false
authorJaven O'Neal <onealj@apache.org>
Sun, 11 Sep 2016 03:37:56 +0000 (03:37 +0000)
committerJaven O'Neal <onealj@apache.org>
Sun, 11 Sep 2016 03:37:56 +0000 (03:37 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1760219 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/usermodel/DataFormatter.java
src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java

index ee6583937bc30554160389acf11652401137bfa7..61a5092f2264a91015f44399fed298b488a724f3 100644 (file)
@@ -895,7 +895,7 @@ public class DataFormatter implements Observer {
                 return cell.getRichStringCellValue().getString();
 
             case BOOLEAN :
-                return String.valueOf(cell.getBooleanCellValue());
+                return cell.getBooleanCellValue() ? "TRUE" : "FALSE";
             case BLANK :
                 return "";
             case ERROR:
index 649bddf9b4e7641a8970158c25bb1428a6fd88b3..50276ae2812846c1631c77b12e99f2ce6967b1ad 100644 (file)
@@ -597,6 +597,27 @@ public class TestDataFormatter {
         }
     }
 
+    @Test
+    public void testBoolean() throws IOException {
+        DataFormatter formatter = new DataFormatter();
+
+        // Create a spreadsheet with some TRUE/FALSE boolean values in it
+        Workbook wb = new HSSFWorkbook();
+        try {
+            Sheet s = wb.createSheet();
+            Row r = s.createRow(0);
+            Cell c = r.createCell(0);
+
+            c.setCellValue(true);
+            assertEquals("TRUE", formatter.formatCellValue(c));
+
+            c.setCellValue(false);
+            assertEquals("FALSE", formatter.formatCellValue(c));
+        } finally {
+            wb.close();
+        }
+    }
+
     /**
      * While we don't currently support using a locale code at
      *  the start of a format string to format it differently, we