c#,将多个系列添加到图表中 [英] c#, adding multiple series to a graph

查看:165
本文介绍了c#,将多个系列添加到图表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在同一工作簿中的不同工作表中绘制数据图表(条形图)。每个工作表中表示的数据是相同的,并且应用程序的目的是获得数据的年度比较。目前我正在使用
一个范围,因此我得到了一个图表,但我不确定它是否是正确的对象,如果我想绘制多个范围。有人可以指导我朝正确的方向发展吗?

I need to draw a graph (bar chart) of data across different worksheets in the same workbook. The data represented in each worksheet is the same, and the purpose of the application is to get a year on year comparison, of the data. At the moment i am using a range and i thereby do get a graph, but i am not sure that it is the right object to use, if I want to draw across multiple ranges. Can someone please direct me in the right direction?

 


      Excel.Workbook     workBook;<br/>      Excel.Worksheet     workSheet;<br/>      Excel.ApplicationClass app = new ApplicationClass(); <br/><br/>      object misValue = System.Reflection.Missing.Value;<br/>      Excel.Range chartRange;

      Excel.ChartObjects xlCharts = (Excel.ChartObjects)workSheet.ChartObjects(Type.Missing);
      Excel.ChartObject myChart = (Excel.ChartObject)xlCharts.Add(10, 80, 300, 250);
      Excel.Chart chartPage = myChart.Chart;

      chartRange = workSheet.get_Range("E4", "L4");
      chartPage.SetSourceData(chartRange, misValue);
      chartPage.ChartType = Excel.XlChartType.xlColumnClustered;

推荐答案

你好Harriet

Hi Harriet

因为你的问题没有集中关于VSTO技术,VSTO本身不适用于图表,我正在将您的问题转移到Excel for Developers论坛,在那里您可以找到应用程序专家。您将有更好的机会获得知识渊博的
答案,了解如何获取图表数据的不连续范围。

As your question does not center on the VSTO technology, and VSTO itself doesn't work with charting, I'm moving your question to the Excel for Developers forum, where you'll find the application specialists. You'll have a better chance of getting a knowledgeable answer there about how to pick up discontinuous ranges for chart data.


这篇关于c#,将多个系列添加到图表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆