Hi,
As per my requirement i need to clear out everything in the chart and just set a chart title.
I am clearing all the series, categories and chartdata workbook and then setting the chart title but it generates an empty shape without any chart title.
Please find attached the source and output file and also
Below is my code
using (Presentation sourcePresentation = new Presentation(dataDir + “Aspos_Source_Issue_ClearData.pptx”))
{
var sourceSlides = sourcePresentation.Slides;
var generatedPres = new Presentation();
generatedPres.Slides.RemoveAt(0);
generatedPres.Masters.RemoveUnused(true);
generatedPres.ViewProperties.SlideViewProperties.Scale = sourcePresentation.ViewProperties.SlideViewProperties.Scale;
var mainPage = generatedPres.Slides.InsertClone(0, sourceSlides[0]);
var chart = (Chart) mainPage.Shapes[0];
chart.ChartData.Categories.Clear();
chart.ChartData.Series.Clear();
chart.ChartData.ChartDataWorkbook.Clear(0);
if (chart.ChartTitle.TextFrameForOverriding != null)
{
chart.ChartTitle.TextFrameForOverriding.Text = "No Data available";
}
else
{
chart.ChartTitle.AddTextFrameForOverriding("No Data available");
chart.ChartTitle.TextFrameForOverriding.TextFrameFormat.CenterText = NullableBool.True;
chart.ChartTitle.Height = 20;
chart.HasTitle = true;
}
// Save presentation
generatedPres.Save(dataDir + "Aspose_Output_Issue_ClearData.pptx", SaveFormat.Pptx);
Console.WriteLine("Presentation Created");
}
Content.zip (87.9 KB)