bug 60025: DataFormatter should print booleans as TRUE/FALSE, not true/false

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1760219 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-09-11 03:37:56 +00:00
parent 5409095923
commit adfd0d7f6c
2 changed files with 22 additions and 1 deletions

View 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:

View 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