RakeshBhandari
asked on
Combination Chart
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
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
ASKER
Hi
Thanks for your answer. But when i building application geting error like
The name 'XlAxisGroup' does not exist in the current context
Error 13 The type or namespace name 'Axis' could not be found (are you missing a using directive or an assembly reference?)
Error 14 The name 'XlAxisType' does not exist in the current context
Error 15 The name 'XlAxisGroup' does not exist in the current context
Error 16 The name 'XlCategoryType' does not exist in the current context
Error 17 The type or namespace name 'Axis' could not be found (are you missing a using directive or an assembly reference?)
Thanks for your answer. But when i building application geting error like
The name 'XlAxisGroup' does not exist in the current context
Error 13 The type or namespace name 'Axis' could not be found (are you missing a using directive or an assembly reference?)
Error 14 The name 'XlAxisType' does not exist in the current context
Error 15 The name 'XlAxisGroup' does not exist in the current context
Error 16 The name 'XlCategoryType' does not exist in the current context
Error 17 The type or namespace name 'Axis' could not be found (are you missing a using directive or an assembly reference?)
You need to add a reference to either or both of
Microsoft.Office.Interop
Microsoft.Office.Interop.E xcel
Microsoft.Office.Interop
Microsoft.Office.Interop.E
ASKER
Yes. now its working
thank you
thank you
ASKER
Hi
Thanks for your answer. I geting output. But in output in datepart(X axis) Non feeded Date like 6/05/2010, 6/6/2010, 6/12/2010, 6/13/2010 ............. coming. how can i avoid those dates ?
Thanks for your answer. I geting output. But in output in datepart(X axis) Non feeded Date like 6/05/2010, 6/6/2010, 6/12/2010, 6/13/2010 ............. coming. how can i avoid those dates ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window