We help IT Professionals succeed at work.

How make combination of column and line  Graph  in Excel  through visual studio 2008 C#

RakeshBhandari
RakeshBhandari used Ask the Experts™
on
I has 3  values Intrest, price  and Date.  I need  Intrest values in  Bar and price in Line in same graph. How create in execl  through  visual studio 2008 with  c# ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2009

Commented:

Author

Commented:
Hi,
     Thanks for for suggestion.  Those url giving how make normal chart like bar or line. But  i need  combination of
bar and line  graphs in single  graphs  in exce  through visual studio 2008  c#  
Top Expert 2009

Commented:

Commented:
If you don't have to use Excel...then check this out, it has a lot of options.
http://zedgraph.org/wiki/index.php?title=Main_Page
 

Author

Commented:
Hi,
 I tried http://clear-lines.com/blog/post/Create-an-Excel-Line-e28093-Column-combination-chart-in-C-revisited.aspx
 i  not geting any  chart  please find attachment and  code.
Sheet Name " Mychart  " is  My Output.
Sheet1 One my input data.
i giving  you my code also.





 
 private void btnGet_Click(object sender, EventArgs e)
        {


            Excel.Application xlAppDelComp;
             Excel.Worksheet xlWorkSheetDelComp;
            object misValueDelComp = System.Reflection.Missing.Value;
           
            xlAppDelComp = new MyExcel.ApplicationClass();
            xlWorkBookDelComp = xlAppDelComp.Workbooks.Add(misValueDelComp);
   xlWorkSheetDelComp = (MyExcel.Worksheet)xlWorkBookDelComp.Worksheets.get_Item(1);
   Excel.Range oResizeRange;

oResizeRange = xlWorkSheetDelComp .get_Range("A1:C20",Missing.Value).get_Resize(Missing.Value, 20);

 Excel.Chart chart = AddChart(xlWorkBookDelComp, " mychart ", "the chart title", Excel.XlChartType.xlColumnClustered, oResizeRange, Excel.XlRowCol.xlRows);

Excel.Series series = (Excel.Series)chart.SeriesCollection(2);
            series.ChartType = Excel.XlChartType.xlLine;


            xlWorkBookDelComp.SaveAs("DelComp 1.xls", MyExcel.XlFileFormat.xlWorkbookNormal, misValueDelComp, misValueDelComp, misValueDelComp, misValueDelComp, MyExcel.XlSaveAsAccessMode.xlExclusive, misValueDelComp, misValueDelComp, misValueDelComp, misValueDelComp, misValueDelComp);
}




 public static Excel.Chart AddChart(Excel.Workbook workbook, string chartSheetName, string title, Excel.XlChartType chartType, Excel.Range dataRange, Excel.XlRowCol byRowOrCol)
             {
                 Excel.Chart chart;
                 chart = (Excel.Chart)workbook.Charts.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                 chart.ChartType = chartType;
                 chart.Location(Excel.XlChartLocation.xlLocationAutomatic, chartSheetName);
                 chart.SetSourceData(dataRange, byRowOrCol);
                 chart.HasTitle = true;
                 chart.ChartTitle.Text = title;
                 return chart;
             }

Open in new window

DelComp-1.xls
Top Expert 2009
Commented:
Rakesh, seems like you've created a duplicate issue on this and it is resolved.

http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_26304862.html

Please don't do this. It takes time on behalf of experts to go through with these issues and if you create duplicates, you're only duplicating experts' work. It'll be more frustrating when you have a few experts working on one while the other one is already resolved.

Please close this issue.

Arun

Author

Commented:
I didn't get proper answer
Top Expert 2009

Commented:
If you did not get a proper answer, you can click the 'Request Attention' button on the issue. This will get others attention.

Arun