如何使用 Epplus 将两个具有不同类型图表的系列放入控制图中?

How to put two series with different types of charts inside a control chart using Epplus?

我正在尝试使用 EPPLUS 将两种类型的图表组合成一个图形图表,如果你能帮助我,我将不胜感激

controller.cs

public ActionResult ExportarExcel()
{    
    var myChart2 = ws.Drawings.AddChart("chart", eChartType.ColumnClustered);

    /*//Define las series para el cuadro
    var series = myChart.Series.Add("C7: E7", "C6: E6");
    myChart.Border.Fill.Color = System.Drawing.Color.Green;
    myChart.Title.Text = "My Chart";
    myChart.SetSize(500, 400);

    //Agregar a la 6ta fila y a la 6ta columna
    myChart.SetPosition(6, 0, 10, 0);*/



    //Define las series para el cuadro
    /*var series = myChart2.Series.Add("C7: E7", "C6: E6");
    myChart2.Border.Fill.Color = System.Drawing.Color.Green;
    myChart2.Title.Text = "My Chart";
    myChart2.SetSize(500, 400);*/


    //Agregar a la 6ta fila y a la 6ta columna
    myChart2.SetPosition(6, 0, 10, 0);

    ws.Cells["A:AZ"].AutoFitColumns();


    MemoryStream memoryStream = new MemoryStream();
    pkg.SaveAs(memoryStream);
    memoryStream.Position = 0;

    return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { FileDownloadName = "Gestion_horas.xlsx" };
}

我想使用我从应用程序带来的数据获取的图像示例

这是对我的评论的正确回答。如果有意义的话,只需要将 myChart2 放在 myChart1 的区域内:

[TestMethod]
public void Chart_Two_Series()
{
    // existingFile = new FileInfo(@"c:\temp\temp.xlsx");
    var fileInfo = new FileInfo(@"c:\temp\Chart_Two_Series.xlsx");
    if (fileInfo.Exists)
        fileInfo.Delete();

    using (var pck = new ExcelPackage(fileInfo))
    {
        var ws = pck.Workbook.Worksheets.Add("Content");

        //Some data
        ws.Cells["C5"].Value = "amarillo";
        ws.Cells["C6"].Value = 12;
        ws.Cells["C7"].Value = 485;

        ws.Cells["D5"].Value = "rojo";
        ws.Cells["D6"].Value = 121;
        ws.Cells["D7"].Value = 77;

        ws.Cells["E5"].Value = "verde";
        ws.Cells["E6"].Value = 548;
        ws.Cells["E7"].Value = 44;

        var myChart = ws.Drawings.AddChart("chart", eChartType.ColumnClustered);

        //Define las series para el cuadro
        var series = myChart.Series.Add("C6:E6", "C5:E5");
        myChart.Border.Fill.Color = System.Drawing.Color.Green;
        myChart.Title.Text = "My Chart";
        myChart.SetSize(500, 400);

        //Agregar a la 6ta fila y a la 6ta columna
        myChart.SetPosition(6, 0, 10, 0);

        //Define las series para el cuadro
        var myChart2 = myChart.PlotArea.ChartTypes.Add(eChartType.Line);
        var series2 = myChart2.Series.Add("C7:E7", "C5:E5");

        ws.Cells["A:AZ"].AutoFitColumns();
        pck.Save();
    }
}

这在输出中给出了这个: