title: Create LineChart using openxml
body: <p>I'm trying to create a new LineChart on excel worksheet, and i don't know how can i feel data on this chart and how to add values for each series.
  The following is what i try to do:</p>
  
  <pre><code>    static void Main(string[] args)
      {
          string docName = @"myFile.xlsx";
          string worksheetName = "Sheet1";
          string title = "My Chart";
          InsertChartInSpreadsheet(docName, worksheetName, title);
      }
  
  
      private static void InsertChartInSpreadsheet(string docName, string worksheetName, string title)
      {
  
      // Open Document for editing
          using (SpreadsheetDocument document = SpreadsheetDocument.Open(docName, true))
          {
              IEnumerable&lt;Sheet&gt; sheets = document.WorkbookPart.Workbook.Descendants&lt;Sheet&gt;().
      Where(s =&gt; s.Name == worksheetName);
              if (sheets.Count() == 0)
              {
                  // The specified worksheet does not exist.
                  return;
              }
  
              WorksheetPart worksheetPart = (WorksheetPart)document.WorkbookPart.GetPartById(sheets.First().Id);
  
              // Add a new drawing to the worksheet.
              DrawingsPart drawingsPart = worksheetPart.AddNewPart&lt;DrawingsPart&gt;();
              worksheetPart.Worksheet.Append(new DocumentFormat.OpenXml.Spreadsheet.Drawing() { Id = worksheetPart.GetIdOfPart(drawingsPart) });
              worksheetPart.Worksheet.Save();
  
              // Add a new chart and set the chart language to English-US.
              ChartPart chartPart = drawingsPart.AddNewPart&lt;ChartPart&gt;();
              chartPart.ChartSpace = new ChartSpace();
              chartPart.ChartSpace.Append(new EditingLanguage() { Val = new StringValue("en-US") });
              DocumentFormat.OpenXml.Drawing.Charts.Chart chart = chartPart.ChartSpace.AppendChild&lt;DocumentFormat.OpenXml.Drawing.Charts.Chart&gt;(
                  new DocumentFormat.OpenXml.Drawing.Charts.Chart());
  
              // Create a new clustered column chart.
              PlotArea plotArea = chart.AppendChild&lt;PlotArea&gt;(new PlotArea());
              Layout layout = plotArea.AppendChild&lt;Layout&gt;(new Layout());
              uint i = 0;
              LineChart lineChart = plotArea.AppendChild&lt;LineChart&gt;(new LineChart());
              LineChartSeries[] series = new LineChartSeries() {} ;
              uint j ; 
              // add series to the lineChart
              for (LineChartSeries s in series) {
                  s = lineChart.AppendChild&lt;LineChartSeries&gt;(new LineChartSeries());
                  s.SeriesText = new SeriesText(new NumericValue() { Text = "Ser "+j } );
                  series1.Index = new Index() { Val = new UInt32Value(j) };
                  series1.Order = new Order() { Val = new UInt32Value(j) } ;
                  j++;
              }
              i = 1;
  
              /***
              Here is my question , how can i add values to my chart
              Example data: 
                      Ser1    Ser2    Ser3    Ser4
              2010    5       6       12      41
              2011    65      1       31      43
              2012    75      8       64      40
              2013    12      31      47      66
              ***/
  
              // Save the chart part.
              chartPart.ChartSpace.Save();
              /* Here i'll add the position of the chart on the worksheet */ 
              // Save the WorksheetDrawing object.
              drawingsPart.WorksheetDrawing.Save();
          }
      }
  </code></pre>
  
  <p>in the code above i gave an example for the data that i want to feel on my chart :</p>
  
  <pre><code>                    Ser1    Ser2    Ser3    Ser4
              2010    5       6       12      41
              2011    65      1       31      43
              2012    75      8       64      40
              2013    12      31      47      66
  </code></pre>
  
  <p>i'm beginner on C# and OpenXml , please help me :-) 
  thank you.</p>