本文介绍了在excel第二张表中创建图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个C#Interop代码,用excel创建报表,并在第二张表中创建图表。我能够创建图表,但它正在第一张表中。请帮助在第二张表中获得相同的内容。我的代码在这里。
Hi, I am writing a C# Interop code to create report in excel with chart in 2nd sheet. I am able create chart, but it is coming in first sheet. Please help get the same in second sheet. My code is here.
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;
chartRange = sheet0.get_Range("AN1", "AP6");
chartPage.SetSourceData(chartRange, misValue);
chartPage.ChartType = XlChartType.xlColumnClustered;
推荐答案
Worksheet sheet2 = workbook.Worksheets[1];
最好的问候
Muthuraja
Best Regards
Muthuraja
chartPage.Location(XlChartLocation.xlLocationAsNewSheet, "Chart Name");
这篇关于在excel第二张表中创建图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!