Free Support Forum - aspose.com

Chart Title not working

Hi,I am trying to set Chart Title Property for chart.I am using following code for MSO Charts.

chartObj.ChartTitle.Text.Text =" Sample Title "

But it is not reflecting in the output.

Can you please let me know how we can set that property.

Thanks,

Amit

Hi,I am trying to set Chart Title Property for chart.I am using following code for MSO Charts.

chartObj.ChartTitle.Text.Text =" Sample Title "

But it is not reflecting in the output.

Can you please let me know how we can set that property.

Thanks,

Amit

Hi Amit,


Please use the following sample code for setting the chart title. Please share, if I may help you further in this regard.

//Instantiate PresentationEx class that represents PPTX file
PresentationEx pres = new PresentationEx();

//Access first slide
SlideEx sld = pres.Slides[0];

// Add chart with default data
ChartEx chart = sld.Shapes.AddChart(ChartTypeEx.ClusteredBar, 0, 0, 500, 500);

//Setting chart Title
chart.ChartTitle.Text.Text = “Sample Title”;
chart.ChartTitle.Text.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillTypeEx.Solid;
chart.ChartTitle.Text.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Red;
chart.ChartTitle.Text.Paragraphs[0].Portions[0].PortionFormat.FontBold=NullableBool.True;
chart.ChartTitle.Text.Paragraphs[0].Portions[0].PortionFormat.FontBold = NullableBool.True;
chart.ChartTitle.Text.Paragraphs[0].Portions[0].PortionFormat.FontItalic = NullableBool.True;
chart.ChartTitle.Text.Paragraphs[0].Portions[0].PortionFormat.FontUnderline = TextUnderlineTypeEx.Dashed;
chart.ChartTitle.Text.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 14;

chart.ChartTitle.Text.CenterText = true;
chart.ChartTitle.Height = 20;
chart.HasTitle = true;


// Save presentation with chart
pres.Write(@“D:\Aspose Data\AsposeChart.pptx”);

Many Thanks,