poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 54786] Date formatting does not support double-quotes as escape-character as Excel does
Date Thu, 04 Apr 2013 06:12:05 GMT

--- Comment #3 from Dominik Stadler <dominik.stadler@gmx.at> ---
Created attachment 30146
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=30146&action=edit
Sample Excel file having formatting using doulbe quotes as escape characters

The attached file shows the conditional date formatting using TEXT() with two
double quotes as escape characters. I.e. cell A1 contains the formula 

=TEXT(B1; "[h]""h"" m""m""")

In Excel, this formats Cell B1 the number of hours with a trailing "h" and the
number of minutes with a trailing "m". If I calculate this formula with POI, I
get 0"0" 15"15", i.e. h and m are replaced twice with hours/minutes and one of
the two double-quotes are removed.

The following unit test fails with the attached file, but I would expect it to
work fine:

    public void test() throws IOException {
        InputStream inp = new FileInputStream(new File("testsrc/test.xlsx"));
        final Workbook wb;
        try {
            wb = new XSSFWorkbook(inp);
        } finally {

        Sheet sheet = wb.getSheetAt(0);

        Row row = sheet.getRow(0);
        Cell cell = row.getCell(0);

        FormulaEvaluator evaluator =
        CellValue cellValue = evaluator.evaluate(cell);
        assertEquals(Cell.CELL_TYPE_STRING, cellValue.getCellType());

        String stringValue = cellValue.getStringValue();
        assertEquals("0h 15m", stringValue);

You are receiving this mail because:
You are the assignee for the bug.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org

View raw message