Manage conditional formatting style using Aspose.Cells for Java

Hi. I found, that since version 8.9.2 conditional formating is broken (either we used it incorrectly)


There is test:

Part of sheet is under conditional formatting. Cell M18 is part of it

@Test
public void conditionalFormatting() throws Exception {
Workbook workbook = new Workbook(“D://in.xlsx”);

Worksheet worksheet = workbook.getWorksheets().get(0);

Cell cell = worksheet.getCells().get(“M18”);

CalculationOptions options = new CalculationOptions();
options.setIgnoreError(true);
cell.calculate(options);

ConditionalFormattingResult result = cell.getConditionalFormattingResult();

FormatConditionCollection[] conditions = cell.getFormatConditions();
for (FormatConditionCollection collection : conditions) {
for (int i = 0; i < collection.getCount(); i++) {
FormatCondition condition = collection.get(i);

System.out.print(condition.getText());
}
}

Style style = cell.getDisplayStyle();
Color color = style.getBackgroundColor();
System.out.println(color.getA() + " " + color.getR() + " " + color.getG() + " " + color.getB());

}
but this code returns 0 0 0 0 for background color of cell.

Best regards. Alexey

Hi,


Thanks for your posting and using Aspose.Cells.

Please use the foreground color property of cell display style i.e.

Cell.getDisplayStyle().getForegroundColor();

However, your issue still occurs with cell M18 but not with other cells. Therefore, we have logged this issue in our database for investigation and a fix.

This issue has been logged as

  • CELLSJAVA-42257 - Conditional formatting style is broken

Thanks for quick answer. Can you please clarify a difference between backgroundColor and foregroundColor?

Hi,


Thanks for your posting and using Aspose.Cells.

Foreground color is actually the fill color of the cell. Background color is a second color when fill type is like gradient fill.

Please see this screenshot. Here, cell is filled with yellow color. It is a foreground color of the cell.

But when there is a gradient fill, there needs two colors. The first color is foreground color and second color is background color.

Hi,

Thanks for using Aspose.Cells.

Please download and try the following latest fix: Aspose.Cells for Java (Latest Version) and let us know your feedback.

Hi . Now it works for me. Thanks

Hi,

Thanks for your feedback and using Aspose.Cells.

It is good to know that your issue is resolved with the latest fix. Let us know if you encounter any other issue, we will be glad to look into it and help you further.

The issues you have found earlier (filed as CELLSJAVA-42257) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.