https://bz.apache.org/bugzilla/show_bug.cgi?id=61007
Bug ID: 61007
Summary: cell format evaluation doesn't handle range conditions
Product: POI
Version: 3.16-FINAL
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: SS Common
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
It is poorly documented, but Excel supports numeric range conditions in cell
format strings. POI currently doesn't handle these.
There is a comment in DataFormatter.getFormat(double, int, String) that
mentions needing to combine the Java Format compatible parsing with the
general-case CellFormat logic.
Interestingly, the following test passes when I change the condition in the
above method that calls CellFormat in all cases where the format contains a
semicolon, instead of only when it contains 2 or more. Doing that breaks
testFractions(), however, so CellFormat doesn't handle everything.
Not sure the best way to handle this, perhaps just send conditional format
strings to CellFormat also, with another targeted boolean expression?
Test case I added to TestDataFormatter:
@Test
public void testConditionalRanges() {
DataFormatter dfUS = new DataFormatter(Locale.US);
String format = "[>=10]#,##0;[<10]0.0";
assertEquals("Wrong format for " + format, "17,876",
dfUS.formatRawCellContents(17876.000, -1, format));
assertEquals("Wrong format for " + format, "9.7",
dfUS.formatRawCellContents(9.71, -1, format));
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]