Conditional formatting error

Hi. I have found, that cell.getDisplayStyle() returns now incorrect value, that should be returned only when condition is true.

@Test
public void test() throws Exception {
    Workbook workbook = new Workbook("E://in.xlsx");

    Cell cell = workbook.getWorksheets().get(0).getCells().get("K13");
    Style style = cell.getDisplayStyle();

    Color color = style.getForegroundColor();
    byte red = color.getR();
    byte green = color.getG();
    byte blue = color.getB();

    System.out.println(red + "," + green + "," + blue);
}

in.zip (7.6 KB)

Best regards. Alexey

@makarovalv,

Thanks for the sample code and template file.

After an initial test, I am able to reproduce the issue as you mentioned by using the following sample code with your template file. I found an issue with conditional formatting in Style.getDisplayStyle method. I noticed it gives same values whether the condition is true or false.
e.g
Sample code:

Workbook workbook = new Workbook("f:\\files\\in.xlsx");

        Cell cell = workbook.getWorksheets().get(0).getCells().get("K13");
        Style style = cell.getDisplayStyle();

        Color color = style.getForegroundColor();
        byte red = color.getR();
        byte green = color.getG();
        byte blue = color.getB();

        System.out.println("Condition False: " + red + "," + green + "," + blue);

        cell.putValue(5);

        style = cell.getDisplayStyle();

        color = style.getForegroundColor();
        red = color.getR();
        green = color.getG();
        blue = color.getB();

        System.out.println("Condition True: " + red + "," + green + "," + blue);

Output:

Condition False: 112,-83,71
Condition True: 112,-83,71 //Even the green value is not right.

I have logged a ticket with an id “CELLSJAVA-42932” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

@makarovalv,
Please try our latest version/fix: Aspose.Cells for Java v18.5.7:
aspose-cells-19.5.7.zip (6.5 MB)

Your issue should be fixed in it.

Let us know your feedback.

The issues you have found earlier (filed as CELLSJAVA-42932) have been fixed in Aspose.Cells for Java 19.6. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi