Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用EPPlus在同一图表上绘制两种图表_C#_Excel 2007_Epplus - Fatal编程技术网

C# 如何使用EPPlus在同一图表上绘制两种图表

C# 如何使用EPPlus在同一图表上绘制两种图表,c#,excel-2007,epplus,C#,Excel 2007,Epplus,我想在EPPlus(帮助导出Excel文件的COM)中的一个图表上绘制两个不同类型的系列(即柱和线)。任何人都知道怎么做。提前谢谢。最后,我找到了答案。 链接参考: 如何将具有不同图表类型的系列添加到图表中? 这是你怎么做的 ExcelChart chart = worksheet.Drawings.AddChart("chtLine", eChartType.LineMarkers); var serie1= chart.Series.Add(Worksheet.Cells["

我想在EPPlus(帮助导出Excel文件的COM)中的一个图表上绘制两个不同类型的系列(即柱和线)。任何人都知道怎么做。提前谢谢。

最后,我找到了答案。 链接参考:

如何将具有不同图表类型的系列添加到图表中?

这是你怎么做的

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"]);

你可以这样做

var chartType2 = chart.PlotArea.ChartTypes.Add(eChartType.ColumnClustered)as ExcelBarChart;
(ExcelBarChartSerie) serie2 = (ExcelBarChartSerie) chartType2.Series.Add(Worksheet.Cells["C1:C4"],Worksheet.Cells["A1:A4"]);
serie2.DataLabel.ShowValue = true;

您知道我如何将datalabel.showvalue=true仅适用于系列2吗??提前谢谢