You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by si...@gmail.com, si...@gmail.com on 2018/06/21 08:54:30 UTC

wrong format cell value

Hello everyone.

I'm trying to implement an accountancy custom data format.
I start from one of your examples but even your examples provide an different output. 
It seems the grouping symbol is ignored.
Do you have any thoughts?

  /**
     * Using a single quote (') instead of a comma (,) as
     *  a number separator, eg 1000 -> 1'000
     */
    @Test
    public final void test55265() {
        Workbook wb = new HSSFWorkbook();
        DataFormatter formatter = new DataFormatter();
        DataFormat fmt = wb.createDataFormat();
        Sheet sheet = wb.createSheet();
        Row r = sheet.createRow(0);

        CellStyle cs = wb.createCellStyle();
        cs.setDataFormat(fmt.getFormat("#'##0"));

        Cell zero = r.createCell(0);
        zero.setCellValue(0);
        zero.setCellStyle(cs);

        Cell sml = r.createCell(1);
        sml.setCellValue(12);
        sml.setCellStyle(cs);

        Cell med = r.createCell(2);
        med.setCellValue(1234);
        med.setCellStyle(cs);

        Cell lge = r.createCell(3);
        lge.setCellValue(12345678);
        lge.setCellStyle(cs);

        assertEquals("0", formatter.formatCellValue(zero));
        assertEquals("12", formatter.formatCellValue(sml));
        assertEquals("1'234", formatter.formatCellValue(med));
        assertEquals("12'345'678", formatter.formatCellValue(lge));
    }

org.junit.ComparisonFailure: 
Expected :1'234
Actual   :1234


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


Re: wrong format cell value

Posted by "pj.fanning" <fa...@yahoo.com>.
https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/DataFormatter.html

includes descriptions about how to set locales



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

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