c#-excel interop - create chart on workbook as opposed to in a sheet
- by david.barkhuizen
Using c# MS Excel interop library, I would like to programmatically create a new chart on the workbook, as opposed to on an a sheet.
The code below allows me to create a chart on an existing _Worksheet (sheet).
using using Microsoft.Office.Interop.Excel;
_Worksheet sheet; (assume this is a reference to a valid _Worksheet object)
ChartObjects charts = (ChartObjects)sheet.ChartObjects(Type.Missing);
ChartObject chartObject = (ChartObject)charts.Add(10, 80, 300, 250);
Chart chart = chartObject.Chart;
chart.ChartType = XlChartType.xlXYScatter;
Does anyone know how to rather go about creating a chart on the workbook (i.e. where the chart is the sheet).