c#中的Excel图表控件... [英] Excel Chart control in c# ...
本文介绍了c#中的Excel图表控件...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好我的朋友
我的程序有问题,我正在使用ClassMicrosoft.Office.Interop.Excel而我无法控制Excel图表,这意味着我只想从一列创建一个图表,但它会从所有列创建一个图表。
我使用的是Microsoft网站上的代码:
https://support.microsoft.com/en-us/kb/302084 [ ^ ]
请帮助我。
Hello my friends
I have a problem with my program,I am using Class "Microsoft.Office.Interop.Excel" and I can not control the Excel chart,This means that I want create a chart from only one column but it create a chart from all column.
I am using this code from Microsoft Web Site:
https://support.microsoft.com/en-us/kb/302084[^]
please help me.
推荐答案
我认为您必须手动创建数据并以这种方式使用数据:
http:// clear-lines.com/blog/post/Create-an-Excel-chart-in-C-without-worksheet-data.aspx [ ^ ]
I think you would have to create a dataseries manually and consume the data that way:
http://clear-lines.com/blog/post/Create-an-Excel-chart-in-C-without-worksheet-data.aspx[^]
var excel = this.Application;
var workbook = excel.ActiveWorkbook;
var charts = workbook.Charts;
var chart = (Chart)charts.Add();
chart.ChartType = Excel.XlChartType.xlLine;
chart.Location(XlChartLocation.xlLocationAsNewSheet, "Tab Name");
var seriesCollection = (SeriesCollection)chart.SeriesCollection();
var series = seriesCollection.NewSeries();
series.Values = new double[] {1d, 3d, 2d, 5d};
series.XValues = new string[] {"A", "B", "C", "D"};
series.Name = "Series Name";
你可以很容易地改变它以适合你的目的。
You could easily change this to fit your purpose.
这篇关于c#中的Excel图表控件...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文