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

Free Support Forum - aspose.com

Chart data label background colors

If I set a chart’s series to have a background color of red for data labels, it works:
series.DataLabels.Area.ForegroundColor = Color.Red;

all data labels for the series are red. But if I then set one label to have different color and text:

series.Points[0].DataLabels.Area.ForegroundColor = Color.Green;
series.Points[0].DataLabels.Text = “changed”;

the text changes for the label, but the background color does not. To be sure it wasn’t the palette, I tried setting the series to green and changing the first data label to red and found that didn’t work either - the whole series is green, the text changes but the label’s background is not red.

I’m saving my workbook as xlsx format. Please advise!

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

I tested your scenario with the attached latest version of Aspose.Cells and it works fine. Following is my sample code:

//Instantiating a Workbook object

Workbook workbook = new Workbook();

//Get First Worksheet of the Workbook

Worksheet ws = workbook.Worksheets[0];

//Set Worksheet Type

ws.Type = SheetType.Chart;

//Add new Data Sheet

Worksheet data = workbook.Worksheets.Add("Data");

Cells cells = data.Cells;







Charts charts = ws.Charts;

int index = charts.Add(ChartType.Pie, 5, 0, 15, 5);

Chart chart = charts[index];

chart.NSeries.Add("Data!B1:B3", true);

chart.NSeries.CategoryData = "Data!A1:A3";

chart.NSeries[0].DataLabels.IsPercentageShown = true;

chart.NSeries[0].DataLabels.Area.ForegroundColor = Color.Red;

chart.NSeries[0].Points[0].DataLabels.Area.ForegroundColor = Color.Green;

chart.NSeries[0].Points[0].DataLabels.Text = "changed";

//Save the workbook


If you still face any problem with the attached latest version, please share your complete code, template and generated excel files and we will check it soon.

Thank You & Best Regards,

Your code did not work for me in version, but does work with the attached version. Thank You