Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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;
Posted 9-Feb-13 0:13am
Shami C332
Comments
CHill60 at 9-Feb-13 17:37pm
   
How is sheet0 set up?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
You can create a object for sheet2 as below,
Worksheet sheet2 = workbook.Worksheets[1];
 
Best Regards
Muthuraja
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Here is the solution..
 
chartPage.Location(XlChartLocation.xlLocationAsNewSheet, "Chart Name");
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 230
2 BillWoodruff 205
3 Sergey Alexandrovich Kryukov 195
4 DamithSL 165
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,650
3 Kornfeld Eliyahu Peter 3,460
4 Sergey Alexandrovich Kryukov 2,811


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100