English 中文(简体)
利用C#创建Excel图表
原标题:Create a chart in Excel using C#

I m在Excel和C#.I ve制作图表时遇到一些麻烦。

            Excel.Range chartRange; 

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

            chartRange = xlWorkSheet.get_Range("A2", "Y2");
            chartPage.SetSourceData(chartRange, misValue);
            chartPage.ChartType = Excel.XlChartType.xlColumnClustered;

不幸的是,我不敢真正确定下一步要做什么。 在这方面,我想做的是:

(1) 应当有几行数据,但两者并不一致(例如:A2:Y2;A4:Y4;A6:Y6;A6:Y6)。 我如何在图表中添加每一项内容?

(2) A1:Y1对我的后代有所有价值,我如何在立法中增加这一价值?

3) 我如何改变这一结构,以便在新的表格上建立每个图表?

感谢!

最佳回答

简单明了问题1:

chartRange = xlWorkSheet.get_Range("B137:Y137, B139:Y139, B141:Y141", Missing.Value);

现在对问题3的答复:

chartPage.Location(Excel.XlChartLocation.xlLocationAsNewSheet, "Chart1");

最后,对问题2的答复只是作为选择的一部分添加行文名称,例如编号2但A而不是B。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签