Here is the sample code (runnable) that I am using and it works fine. The third series is added with green color.
Workbook book1 = new Aspose.Cells.Workbook();
book1.FileFormat = FileFormatType.Xlsx;
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.Scatter;
//Set Properties of categoryaxis title
chart.CategoryAxis.Title.Text = “Units”;
//Set Properties of nseries
int s1_idx = chart.NSeries.Add(“A1:A1”, true);
int s2_idx = chart.NSeries.Add(“A22:A22”, true);
int s3_idx = chart.NSeries.Add(“A42:A42”, true);
chart.NSeries.IsColorVaried = true;
Series s1 = chart.NSeries[s1_idx];
s1.Area.Formatting = FormattingType.Custom;
s1.Marker.Area.ForegroundColor = Color.Red;
s1.XValues = “A2:A21”;
s1.Values = “B2:B21”;
Series s2 = chart.NSeries[s2_idx];
s2.Area.Formatting = FormattingType.Custom;
s2.Marker.Area.ForegroundColor = Color.Yellow;
s2.XValues = “A22:A41”;
s2.Values = “B22:B41”;
Series s3 = chart.NSeries[s3_idx];
s3.Area.Formatting = FormattingType.Custom;
s3.Marker.Area.ForegroundColor = Color.Green;
s3.XValues = “A42:A61”;
s3.Values = “B42:B61”;
chart.ToImage(@“e:\test2\chart1.gif”);
book1.Save(@“e:\test2\outfile.xls”);
If you still find the issue, could you paste your simple runnable code, so that we could check your issue.
Thank you.