poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 58571] New: Date formatting in formulas does not support double-quotes as escape-character as Excel does
Date Mon, 02 Nov 2015 06:40:45 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=58571

            Bug ID: 58571
           Summary: Date formatting in formulas does not support
                    double-quotes as escape-character as Excel does
           Product: POI
           Version: 3.14-dev
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: SS Common
          Assignee: dev@poi.apache.org
          Reporter: dominik.stadler@gmx.at

This is a followup from Bug 54786, the fix applied there is not complete yet,
the following unit-test still fails:

    @Test
    public void testFormula() throws IOException {
        try (Workbook wb = new XSSFWorkbook()) {
            FormulaEvaluator eval =
wb.getCreationHelper().createFormulaEvaluator();

            Sheet sheet = wb.createSheet("test");
            Row row = sheet.createRow(0);
            Cell cell = row.createCell(0);
            cell.setCellFormula("TEXT(B1, \"[h]\"\"h\"\" m\"\"m\"\"\")");

            Cell cellValue = row.createCell(1);
            cellValue.setCellValue(0.0104166666666666);;

            CellValue value = eval.evaluate(cell);
            assertEquals(Cell.CELL_TYPE_STRING, value.getCellType());
            assertEquals("1h 0m", value.getStringValue());
        }
    }

It seems the StringPtg internally stores the two double quotes ("") as one
double quote and the format is passed this way to the TEXT-function and further
on to DataFormatter.formatRawCellContents(). However in Bug 54786 we built the
replacement there on two doulbe-quotes.

Two options:
* Adjust DataFormatter to replace one double quote with a single quote
* Adjust StringPtg to return the doulbe-quotes in the call to getValue()
similar to toString()/toFormulaString()

I am not sure which one is the better option here as both may have side-effects
to existing code/functionality.

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


Mime
View raw message