Bar color changed while converting excel to pdf when using setCrossAt()

I’m using this code to generate a bar chart whose bars will be green if the value is greater than 100 and red if less than. It’s working fine with excel.But the problem arises when it’s getting converted to PDF or PPTX. The bars whose value is less than 100 are also colored green in PDF and PPTX. Kindly do reply ASAP.

sheet.getCharts().get(0).getValueAxis().setCrossAt(100.0);
sheet.getCharts().get(0).getNSeries().get(0).getArea().setForegroundColor(Color.fromArgb(0, 176, 80));
sheet.getCharts().get(0).getNSeries().get(0).getArea().setBackgroundColor(Color.fromArgb(255, 0, 0));
sheet.getCharts().get(0).getNSeries().get(0).getBorder().setVisible(false);
sheet.getCharts().get(0).getNSeries().get(0).getArea().setInvertIfNegative(true);

@sgullapalli1,

Thanks for providing us sample code segment and details.

Please provide us your template Excel file containing the chart (you may simply save to Excel file at the end of your code), we will check it soon.

Thank you.

Hi Amjad,

I’ve attached the code files(.java files), .xlsx file and the corresponding .pdf,.pptx and .emf output files.Please find the attachment.

Thank you.

BarColorChangeInPDF.zip (82.9 KB)

@sgullapalli1,

Thanks for the sample code, template file and output PDF, etc.

After an initial test, I observed the issue as you mentioned by using your sample code with your template file. I found that bars color changed while converting Excel to PDF, The bars whose value is less than 100 are also colored green instead of red in PDF.

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

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

Thank you.

@sgullapalli1,

Please try our latest version/fix: Aspose.Cells for Java v17.8.7:

Your issue should be fixed in it.

Let us know your feedback.

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

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan