You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2017/04/19 16:53:43 UTC
[Bug 61007] New: cell format evaluation doesn't handle range
conditions
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: dev@poi.apache.org
Reporter: gwoolsey@apache.org
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 61007] cell format evaluation doesn't handle range conditions
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61007
--- Comment #2 from Greg Woolsey <gw...@apache.org> ---
Fixed in r1791964. Kept existing test behavior, as changing that broke other
tests too. Implemented specific logic to send formats with multiple
conditional segments to CellFormat in addition to the previous logic to send
anything with 3 or more segments there. Added some tests for this.
--
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
[Bug 61007] cell format evaluation doesn't handle range conditions
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61007
Greg Woolsey <gw...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|3.16-FINAL |3.17-dev
Resolution|--- |FIXED
Status|NEW |RESOLVED
--
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
[Bug 61007] cell format evaluation doesn't handle range conditions
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61007
--- Comment #1 from Greg Woolsey <gw...@apache.org> ---
Turns out the test that failed when I sent all segmented formats to CellFormat
was checking an invalid expected result. The value it has, which is currently
returned by POI, doesn't match the value produced by Excel for the same format
string.
Excel produces the value returned by CellFormat. So I will change the test to
expect the correct value ("correct" defined as the value shown by Excel), and
the logic in DataFormatter to send all multi-part formats to CellFormat. It
already has a cache of format strings, so parsing will only happen once per
format string per ClassLoader hierarchy.
--
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