Set color marker in LineWithDataMarkers chart using Aspose.Cells for .NET in C#

Hi all,
I’m using Chart LineWithDataMarkers and when I set color for Marker and save with excel 2003 format, it not working. But xlsx is working.

Here is my sample code:
Workbook book1 = new Aspose.Cells.Workbook();
book1.FileFormat = FileFormatType.Excel97To2003;

            Worksheet sheet1 = book1.Worksheets[0];

            sheet1.Cells[0, 0].Value = "X";
            sheet1.Cells[0, 1].Value = "Y";

            Random R = new Random();

            for (int i = 1; i < 21; i++)
            {
                sheet1.Cells[i, 0].Value = i;
                sheet1.Cells[i, 1].Value = Math.Round(R.NextDouble(), 1);
            }

            for (int i = 21; i < 41; i++)
            {
                sheet1.Cells[i, 0].Value = i - 20;
                sheet1.Cells[i, 1].Value = 0.8;// Math.Round(R.NextDouble(), 1);
            }


            for (int i = 41; i < 61; i++)
            {
                sheet1.Cells[i, 0].Value = i - 40;
                sheet1.Cells[i, 1].Value = 0.9;// Math.Round(R.NextDouble(), 1);
            }


            int idx = sheet1.Charts.Add(ChartType.LineWithDataMarkers, 1, 3, 20, 20);
            Chart chart = sheet1.Charts[idx];
            chart.Style = 3;
            chart.AutoScaling = true;
            chart.PlotArea.Area.ForegroundColor = Color.White;
            //chart.NSeries.IsColorVaried = true;

            //Set Properties of chart title
            chart.Title.Text = "PCS";
            chart.Type = ChartType.LineWithDataMarkers;

            //Set Properties of categoryaxis title
            chart.CategoryAxis.Title.Text = "Units";

            //Set Properties of nseries
            int s2_idx = chart.NSeries.Add("A22: A22", true);
            int s3_idx = chart.NSeries.Add("A42: A42", true);

            chart.NSeries.IsColorVaried = true;

            chart.NSeries[s2_idx].Area.Formatting = FormattingType.Custom;
            chart.NSeries[s2_idx].Marker.Area.ForegroundColor = Color.Yellow;
            chart.NSeries[s2_idx].Marker.Border.IsVisible = false;

            chart.NSeries[s2_idx].XValues = "A22: A41";
            chart.NSeries[s2_idx].Values = "B22: B41";

            chart.NSeries[s3_idx].Area.Formatting = FormattingType.Custom;
            chart.NSeries[s3_idx].Marker.Area.ForegroundColor = Color.Green;
            chart.NSeries[s3_idx].Marker.Border.IsVisible = false;

            chart.NSeries[s3_idx].XValues = "A42: A61";
            chart.NSeries[s3_idx].Values = "B42: B61";

            book1.Save(@"d:\outfile.xls");

Thanks & best regards

@DungLT,

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46471 - Can't set color marker LineWithDataMarkers in XLS
1 Like

@DungLT,

This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

The issues you have found earlier (filed as ) have been fixed in Aspose.Cells for .NET v18.12. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi

1 Like