Excel图表-未获得图例 [英] Excel chart - Not getting Legends
本文介绍了Excel图表-未获得图例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用C#(互操作)创建一个Excel图表.我正在使用get_Range函数从excel的数据表中获取它.我正确地得到了图表.但是我没有在图形旁边找到 传奇名称 ,它以series0,series1的形式出现.我正在使用以下代码.
I am creating an excel chart using C# (interop). I am using get_Range function to get it from the data sheet in excel. I am getting the graph properly. But I am not getting the Legend names next to graph, it is coming as series0, series1. I am using folowing code.
Range chartRange;
Object misValue = System.Reflection.Missing.Value;
ChartObjects xlCharts = (ChartObjects)sheet0.ChartObjects(Type.Missing);
ChartObject myChart = (ChartObject)xlCharts.Add(10, 70, 250, 250);
Chart chartPage = myChart.Chart;
Chart chartPage1 = myChart.Chart;
chartRange = sheet0.get_Range("$G$45:$G$54,$AT$45:$AT$54", misValue);
chartPage.SetSourceData(chartRange, misValue);
chartPage.ChartType = XlChartType.xlColumnClustered;
chartPage.Location(XlChartLocation.xlLocationAsNewSheet, "Chart");
我应该在get_Range方法中进行哪些更改以在图表中获取图例名称?
What shoud I change in get_Range method to get the Legend names in chart?
谢谢.
推荐答案
尝试遍历系列集合并逐个设置名称.像这样:
Try to iterate over series collection and set the names one by one. Something like this:
foreach (Series series in myChart.SeriesCollection()){
series.Name = "MyName";
}
这篇关于Excel图表-未获得图例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文