Bug 64319 - DataFormatter on conditional format with E in adds a +
Summary: DataFormatter on conditional format with E in adds a +
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-07 08:33 UTC by David Sheldon
Modified: 2020-04-11 15:38 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Sheldon 2020-04-07 08:33:20 UTC
If you have a number format which ends up with an "E" in it, this is replaced by "E+"

If my formatString is "TRUE";"TRUE";"FALSE", I'd expect all non-zero values to be "TRUE", however they are "TRUE+".


This test fails:

    @Test
    public void testBaseFormattingTrue() {
        DataFormatter formatter = new DataFormatter();
        assertThat(formatter.formatRawCellContents(1.0, 170, "\"TRUE\";\"TRUE\";\"FALSE\"")).isEqualTo("TRUE");
    }

and 
        System.out.println(formatter.formatRawCellContents(1.0, 170, "\"POSITIVE\";\"NEGATIVE\";\"ZERO\""));
        System.out.println(formatter.formatRawCellContents(-1.0, 170, "\"POSITIVE\";\"NEGATIVE\";\"ZERO\""));
        System.out.println(formatter.formatRawCellContents(0, 170, "\"POSITIVE\";\"NEGATIVE\";\"ZERO\""));

prints:

POSITIVE+
NE+GATIVE
ZE+RO
Comment 1 Nick Burch 2020-04-07 09:47:24 UTC
This does look like a bug

I've added a more comprehensive unit test in r1876225 which should cover all the various E cases, most of which we are currently failing on...
Comment 2 Nick Burch 2020-04-11 15:38:51 UTC
Hopefully fixed in r1876396.

I have changed the code that adds the + to #e# for 0E+0 so that it checks that it is a format type that needs that change. I've also added unit tests and a few tweaks for some other scientific / exponential formats which don't need the change. (Another case where Excel and Java have different formatting rules, fun!)