Search code examples
c#excel-2007epplus

How to plot 2 kinds of chart on the same chart use EPPlus


I want to draw 2 different type series (i.e. Column & Line) on one chart in EPPlus (a COM helping export Excel file). Anybody know how to do that. Thanks in advance.


Solution

  • Finally, I've found my answer. Link ref: http://epplus.codeplex.com/wikipage?title=FAQ

    How can I add a series with a different chart type to my chart?

    Here's how you do...

    ExcelChart chart = worksheet.Drawings.AddChart("chtLine", eChartType.LineMarkers);        
    var serie1= chart.Series.Add(Worksheet.Cells["B1:B4"],Worksheet.Cells["A1:A4"]);
    //Now for the second chart type we use the chart.PlotArea.ChartTypes collection...
    var chartType2 = chart.PlotArea.ChartTypes.Add(eChartType.ColumnClustered);
    var serie2 = chartType2.Series.Add(Worksheet.Cells["C1:C4"],Worksheet.Cells["A1:A4"]);