troubleshooting Question

Combination Chart

Avatar of RakeshBhandari
RakeshBhandariFlag for India asked on
C#
6 Comments1 Solution1442 ViewsLast Modified:
Hi
    I try to make combination colum and line chart in excel throug c# with vs2008.
 I giving what output i geting and my code and  what  out i need which i manualy created in excel and step
pls find attachment and code

In attachment Mychart sheet Output i geting through c# coding;
Sheet1 from A1 to C20  input i using
 from G4  to N19 my required output
From A24  to A33  Steps for crearing that output


I need to know how make that graph in excel through c# vss2008
private void button4_Click(object sender, EventArgs e)
            
             {
 Excel.Application oXL = new Microsoft.Office.Interop.Excel.Application();
             Excel.Workbook oWB;
             Excel.Worksheet oWS;
             oWB = oXL.Workbooks.Add(Missing.Value);
             oWS = (Excel.Worksheet)oWB.Worksheets.get_Item(1);
             Excel.Range oResizeRange;
             object misValueDelComp = System.Reflection.Missing.Value;
             oResizeRange = oWS.get_Range("A1:C20", Missing.Value).get_Resize(Missing.Value,Missing.Value);

 Excel.Chart chart = AddChart(oWB, " mychart ", "the chart title", Excel.XlChartType.xlColumnClustered, oResizeRange, Excel.XlRowCol.xlRows);
 oWB.SaveAs("TestGraph.xls", Excel.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;
             }
TestGraph.xls
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros