c#-excel interop - create chart on workbook as opposed to in a sheet
Posted
by david.barkhuizen
on Stack Overflow
See other posts from Stack Overflow
or by david.barkhuizen
Published on 2010-06-10T15:05:02Z
Indexed on
2010/06/10
15:22 UTC
Read the original article
Hit count: 357
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).
© Stack Overflow or respective owner