K
Kevin Burton
I am getting an ArgumentException with the message, "This object has no
title." from the following code:
chart.ChartTitle.Text = "Total Sales Comparison";
If I comment out this line the chart is created but the Title is "Chart
Title". What do I need to do to set the chart title?
If it helps here is the code I am using to create the chart:
Excel.Shape shape = ws.Shapes.AddChart(Excel.XlChartType.xlLine, missing,
missing, missing, missing);
shape.Name = "YTDTotalSales";
Excel.Chart chart = shape.Chart;
if (chart != null)
{
chart.SetSourceData(ws.get_Range(string.Format("{0}2:{1}{2}",
(char)('A' + (baseColumn + 0)),
(char)('A' + (baseColumn + 4)), currentTotalList.Count + 2), missing),
missing);
((Excel.Axis)chart.Axes(Excel.XlAxisType.xlCategory,Excel.XlAxisGroup.xlPrimary)).TickLabelPosition = Excel.XlTickLabelPosition.xlTickLabelPositionHigh;
chart.ChartTitle.Text = "Total Sales Comparison";
chart.ApplyLayout(3, missing);
}
Thank you.
Kevin
title." from the following code:
chart.ChartTitle.Text = "Total Sales Comparison";
If I comment out this line the chart is created but the Title is "Chart
Title". What do I need to do to set the chart title?
If it helps here is the code I am using to create the chart:
Excel.Shape shape = ws.Shapes.AddChart(Excel.XlChartType.xlLine, missing,
missing, missing, missing);
shape.Name = "YTDTotalSales";
Excel.Chart chart = shape.Chart;
if (chart != null)
{
chart.SetSourceData(ws.get_Range(string.Format("{0}2:{1}{2}",
(char)('A' + (baseColumn + 0)),
(char)('A' + (baseColumn + 4)), currentTotalList.Count + 2), missing),
missing);
((Excel.Axis)chart.Axes(Excel.XlAxisType.xlCategory,Excel.XlAxisGroup.xlPrimary)).TickLabelPosition = Excel.XlTickLabelPosition.xlTickLabelPositionHigh;
chart.ChartTitle.Text = "Total Sales Comparison";
chart.ApplyLayout(3, missing);
}
Thank you.
Kevin