We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Cells conditional format is working in the file, but not working when programmatically open the file

I have an excel file contains conditional format of VLOOKUP, when put value in the first cell, the border color should turn red for this cell (with conditional format). This is working as expected when I open the file. But when I read the file and get the DisplayStyle() to check the border color, it always shows black.

My code:

        File myFile = new File("/.../Book1.xlsx");
        LoadOptions loadOptions;
        loadOptions = new LoadOptions(LoadFormat.XLSX);
        Workbook workbook = new Workbook(myFile.toString(), loadOptions);
        Worksheet sheet1 = workbook.getWorksheets().get("Sheet1");
        Cell B2 = sheet1.getCells().get("B2");
        Style st = B2.getDisplayStyle();
        Cell A2 = sheet1.getCells().get("A2");

        assertEquals(Color.getRed(), B2.getDisplayStyle().getBorders().getByBorderType(8).getColor());

The conditional format in B2 cell has VLOOKUP and IF functions. And the VLOOKUP content is in another sheet (Sheet2).

This unit test failed with following message
Expected :com.aspose.cells.Color@ffff0000
Actual :com.aspose.cells.Color@ff000000

And I also checked the boolean value of isModified() for B2 after I put value to A2, it’s false.


Book1.xlsx.zip (7.6 KB)

You may please share your sample Excel file for our reference. We will use it for reproducing the issue here and share our feedback accordingly.

Hi @ahsaniqbalsidiqui

Thank you for your reply!
I attached the sample file and modified the code a little bit to show you exactly what I’m doing.

The conditional formatting seems doesn’t work in this case. But if you save the file after you put “myTarget” to A2 and open the file, you’ll see B2 has an expected red border.


Please try our latest fix Aspose.Cells for Java 21.9.4 (attached).
aspose-cells-21.9.4-java.zip (7.4 MB)

I have tested using your exact code and template file and it works fine with it.

Let us know if you still find any issue with new version/fix.