Incorrect Conditional Formatting in Aspose.Cells When Save As PDF

I have created a sample Excel file to reproduce the issue.

test2.zip (9.6 KB)

In the Excel file, I added a conditional formatting to change A1 and B1 to white text color when A3’s value is 1.

image.png (768 位元組)

image.png (828 位元組)

However, after save it to PDF file with Aspose.Cells, the cell B1, which have some text formatting (some text in bold in this sample) is not applying the conditional formatting.

image.png (810 位元組)

p.s. I am using Aspose.Cells 23.1 in my project

@matthew.lo.housing

It sounds like you’re experiencing an issue with conditional formatting not being applied correctly when saving an Excel file as a PDF using Aspose.Cells. This can occur due to the way certain formatting is interpreted during the conversion process.

Cause: The issue may stem from incorrect conditional formatting rules, overlapping rules, or the specific settings used during the PDF conversion.

Solution: Here are some steps to troubleshoot and resolve the issue:

  1. Check Conditional Formatting Rules: Ensure that the conditional formatting rules are set correctly in your Excel file. Overlapping rules or incorrect conditions can lead to unexpected results.

  2. Update Aspose.Cells: Make sure you are using the latest version of Aspose.Cells. Updates often include bug fixes and improvements that could resolve your issue.

  3. Use PdfSaveOptions: When saving the workbook to PDF, utilize the PdfSaveOptions class to specify any additional settings that might help with the rendering of conditional formatting. For example, you can set the compliance level or other rendering options.

    Here’s a simple code snippet to illustrate how to use PdfSaveOptions:

    Workbook workbook = new Workbook("yourfile.xlsx");
    PdfSaveOptions saveOptions = new PdfSaveOptions();
    // Set any specific options if needed
    workbook.save("output.pdf", saveOptions);
    
  4. Test with Simplified Data: Create a simplified version of your Excel file with just the conditional formatting in question. This can help isolate the issue and determine if it’s related to the specific content or formatting in your original file.

  5. Contact Support: If the issue persists, reach out to Aspose support with your sample file. They can provide more targeted assistance and investigate if there’s a specific bug or limitation.

Next Steps: Please try the above steps and let me know if they help resolve the issue. If you continue to experience problems, I can assist you further or help you prepare the necessary information for Aspose support.

Thank you, and I look forward to your response!

The issue persisted, thanks.

@matthew.lo.housing
By testing with sample files and code on the latest version v25.8, we can reproduce the issue. Incorrect conditional formatting when saving file to pdf. Please refer to the attachment. test2_out.pdf (22.7 KB)

Workbook workbook = new Workbook(filePath + "test2.xlsx");
WorksheetCollection worksheets = workbook.getWorksheets();

// Set first worksheet's A3 to 1
worksheets.get(0).getCells().get("A3").setValue(1);

int pageCount = worksheets.getCount();
for (int i=0; i<pageCount; i++) {
    Worksheet worksheet = worksheets.get(i);
    PageSetup pageSetup = worksheet.getPageSetup();
    pageSetup.setPaperSize(PaperSizeType.PAPER_A_4);
    pageSetup.setFitToPages(1, 1);
    pageSetup.setCenterHorizontally(true);
    pageSetup.setCenterVertically(false);
    pageSetup.setTopMargin(0);
    pageSetup.setBottomMargin(0);
    pageSetup.setLeftMargin(0);
    pageSetup.setRightMargin(0);
}
workbook.save(filePath + "test2_out.pdf", SaveFormat.PDF);
System.out.println("done");

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSJAVA-46483

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@matthew.lo.housing,

This is to inform you that your issue (Ticket ID: “CELLSJAVA-46483”) has been resolved. The fix/enhancement will be included in the upcoming release (Aspose.Cells v25.10) that we plan to release in the first half of October 2025. You will be notified in this thread once the new version is published.

The issues you have found earlier (filed as CELLSJAVA-46483) have been fixed in Aspose.Cells for Java 25.10.