exception in creating excel chart by C#
<p>I'm trying to write a program to create a chart in excel by C#.</p>

<p>I've wrote the program and it work correctly in win7pro and Office 2007</p>

<p>but when I execute the program in a system with windows XP sp(3) and office 2003 it throws below error:</p>

<pre><code>Unhandled Exception: System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC
  at Microsoft.Office.Interop.Excel._Chart.ChartWizard(Object Source, Object Gallery, Object Format, Object PlotBy, Object CategoryLabels, Object SeriesLabels, Object HasLegend, Object Title, Object CategoryTitle, Object ValueTitle, Object
 ExtraTitle)
  at ConsoleApplication2.Report.createChart(Worksheet ws, String chartTitle, String xName, String yName)
  at ConsoleApplication2.Report.createReport(List`1 data, String chartTitle, String xName, String yName)
  at CreateExcelWorksheet.Main()
</code></pre>

<p>the code which create chart for me is below:</p>

<pre><code>protected void createChart(Worksheet ws,string chartTitle,string xName,string yName)
    {
      ChartObjects chartObjs = (ChartObjects)ws.ChartObjects(Type.Missing);
      ChartObject chartObj = chartObjs.Add(100, 10, 300, 300);
      Chart xlChart = chartObj.Chart;      
      Range rg;
      rg = ws.get_Range(startCell,endCell);      
      xlChart.ChartWizard(rg, XlChartType.xlXYScatterSmooth, 1, XlRowCol.xlColumns, 0, 0, true, chartTitle, xName, yName, "");
    }
</code></pre>

<p>and the error line is the last one.</p>

<p>does anyone know what should I do?</p>

<p>in addition when I replace the last line with following lines the program works but I need to set some properties like xName and yName and ChartTitle for chart. does anyone know how can I do that?</p>

<pre><code>xlChart.ChartType = XlChartType.xlXYScatterSmoothNoMarkers;
xlChart.SetSourceData(rg, Type.Missing);
</code></pre>

<p>thank you </p>
