Hello,
I am trying to create an Excel chart from C#. I am not a very experieced programmer, so my mistake could be very trivial. The code included is a very simple example. I just wanted to make sure the code runs first before I implement it into my application.
The code is supposed to plot for X values: column A in excel and for Y values: column B in Excel. The code up to the point and including exporting the data to excel runs properly. When I implement the code relating to plotting, I get a COMException; Exception from HRESULT: 0x800A03EC.
-
-
...
-
-
Range theRange6 = theWorkSheet.get_Range("A1", "B50");
-
theRange6.Select();
-
ChartObjects chartobjects = (ChartObjects)theWorkSheet.ChartObjects(Type.Missing);
-
ChartObject chartobject = (ChartObject)chartobjects.Add(10 /*Left*/, 100 /*Top*/, 450 /*Width*/, 250 /*Height*/);
-
_Chart chart = (_Chart)chartobject.Chart;
-
-
//chartobject.Chart.ChartWizard parameters are from MSDN help.
-
chartobject.Chart.ChartWizard(theRange6, XlChartType.xlXYScatterSmooth, 1, XlRowCol.xlColumns, 0, 0, true, "Test", "x", "y", "");
-
-
theApplication.Visible = true;
-
Could you please advise me on what I could be doing wrong? Any help would be greatly appreciated.
Thank you,
rGh