title: Adding a second line to a graph in excel via c#
body: <p>I want to create a simple line on a graph in excel that I have generated with code. I add the data to an excel sheet and can generate a single graph of that data. my code to generate the graph is</p>
  <pre><code>int cRowCount = worksheet.UsedRange.Rows.Count;
          Range employeeNames = worksheet.Range[&quot;A2:A&quot; + cRowCount];
          Range kpiValues = worksheet.Range[&quot;E2:E&quot; + cRowCount];
          Chart kpiChart = (Chart)workbook.Charts.Add(misValue, misValue, 1, misValue);
          kpiChart.SetSourceData(employeeNames, misValue);
  
          kpiChart.ChartType = XlChartType.xlLineMarkers;
  
          var seriesX = (Series)kpiChart.SeriesCollection(1);
  
          seriesX.XValues = employeeNames;
          seriesX.Values = kpiValues;
          
          kpiChart.Legend.Clear();
          workbook.Sheets[&quot;KPI Export&quot;].Move(workbook.Sheets[1]);
          kpiChart.HasTitle = false;
          workbook.Sheets[2].name = &quot;KPI chart&quot;;
  
          // save the application  
          workbook.SaveAs(tbxExcelSave.Text + &quot;\\&quot; + tbxName.Text, XlFileFormat.xlOpenXMLWorkbook,
          misValue, misValue, misValue, misValue, XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
  
          // Exit from the application  
          writeToApp.Quit();
          GC.Collect();
  </code></pre>
  <p>The graph looks as follows.</p>
  <p><a href="https://i.stack.imgur.com/61pO4.png" rel="nofollow noreferrer">Graph of all values</a>
  I now want to use the final data point to create a horizontal line in the same graph as the final data point is the average of all the data points. With this I will be able to see what is above or below the &quot;average&quot; of the data.</p>
  <p>Really all I need to do is add a simple horizontal line to the graph at the Y coordinate of the final value. Any assistance would be greatly appreciated.</p>