Free Support Forum - aspose.com

Add Chart,Table and paragraph in container

Hi team,
I want to add chart,table and paragraph in different-different container(container may be any object) in existing slide so can you help me this is possible or not from dot net code . Once done this things i recommend to purchase licence .

Regards,
Rajiv

@rajivyadav,

I have observed your comments. Can you please visit and explore this documentation link. Please share feedback with us if there is an issue. Also please share your requirements in more details and in form of sample presenation.

Hi Adnan,
I check developer guide but there is not solution as per my requirements .
I add paragraph in existing slide using this below code:
IAutoShape ashp = presentation.Slides[4].Shapes.AddAutoShape(ShapeType.Rectangle, 300, 120, 600, 100);
And add chart in existing slide using this code: IChart charts = presentation.Slides[4].Shapes.AddChart(ChartType.Pie, 20, 50, 300, 250);
But i do not want to give the x axis , y axis, width and height of chart or paragraph because this have fix position and width, if user want to any changes then there will be need to change in code.
So i want to get some container or object(it may be name,ID or others that will be in existing slide) from existing slide using dot net code and set chart or table or paragraph in that container or object.
So please help me if this is possible . For details find screen shot.
image.png (38.2 KB)

@rajivyadav,

I have tried understanding the requirements shared by you and have not been able to understand them. Do you mean to hide the chart axis? Can you please provide a sample presentation with desired chart that you want to generate using Aspose.Slides We will investigate the requirements further on our end to help you out.

Hi Team,

Below snap sot is part of my existing slide with company theme in this slide I want to add chart, table, paragraph etc. from aspose slide code in dot net . Like create pie chart and get container one from code by ID/Name and set pie chart in that container so chart will be plot same as container width and height . Same for paragraph and table .
Let me know if any other clarification .
image.png (20.5 KB)

@rajivyadav,

You can find the shape by using Alternative Text property. You can set the shape name in PowerPoint using Alternative Text and then identify that using Aspose.Slides. Secondly, there is no option to change use any container shape as given in your image as chart, table or other shape. You can achieve your target by accessing the desired object shape using Aspose.Slides Alternative Text property and then using same bounds of that shape, you can add chart, table or other shape as desired. Once the desired shape is added, you can remove the template object shape.

Hi Adnan,

Thanks for quick response and i analyse to Alternative Text code but I am unable to implement these code, so can you change in my code that is attached .
Fetch object or Alternative Text from existing PPT through dot net code and set to chart, table or paragraph .
CodeFile.zip (3.5 KB)

@rajivyadav,

The code for finding shape seems to be fine. I think you are probably wrongly setting the Alternative Text for the shape. Please check following image and you need to set it the same way.

Hi Adnan,
Thanks for cooperation now this is working and i want one more help from you that is render HTML table in slide. Means i have html table in database and i want to display data on slide from html table So please suggest what is way in aspose slide for dot net .
Please find my below html table for reference .

awfsaf sacsac fdsaf sadfdsaf
sas sac as sacs
sasc as sa asa

@rajivyadav,

I have observed your comments. I regret to inform that support to import HTML table in PowerPoint slide is not available in API. A ticket with ID SLIDESNET-37059 is already added in our issue tracking system to provide this support. I also suggest you to please visit following thread for reference as well.

Hi Adnan,
I created to pie chart using aspose slide but i am facing some issue regarding data label and legend setting so can you help me for change setting of data label and space in legend . For more details refer my screenshot and code , So can you change in my code for expected result .
Actual Chart generated by jquery
image.png (17.1 KB)

Generated by aspose slide
image.png (23.8 KB)

Code of aspose slide
#region Add pie chart
string path = Path.Combine(Server.MapPath("~/App_Data/SamplePPTTemplate/"));
using (Presentation presentation = new Presentation(path + “TSCClientPortal.pptx”))
{
ISlide sld = presentation.Slides[4];
IChart charts = (IChart)sld.Shapes[0];
//charts.PlotArea.Height = 0.5f; // chart.Heigh * 0.5 = 400 * 0.5 = 200
//charts.PlotArea.Width = 0.5f; // Chart.Width * 0.5 = 500 * 0.5 = 250
//charts.PlotArea.X = 10f; // chart.X = 500 * 0.25 = 125
//charts.PlotArea.Y = 10f;

            //Add chart title
            charts.ChartTitle.AddTextFrameForOverriding("Pie Chart");

            charts.ChartTitle.TextFrameForOverriding.TextFrameFormat.CenterText = NullableBool.True;
            charts.ChartTitle.Height = 5;
            charts.ChartTitle.Width = 50;
            charts.HasTitle = true;

            // Setting the index of chart data sheet
            int defaultWorksheetIndex1 = 0;

            // Getting the chart data worksheet
            IChartDataWorkbook fact1 = charts.ChartData.ChartDataWorkbook;

            // Delete default generated series and categories
            charts.ChartData.Series.Clear();
            charts.ChartData.Categories.Clear();

            // Adding new categories
            int legendindex = 1;
            foreach (var item in des)
            {
                charts.ChartData.Categories.Add(fact1.GetCell(0, legendindex, 0, item.Category));
                legendindex++;
            }
            charts.Legend.Position = LegendPositionType.Bottom;
            charts.Legend.TextFormat.PortionFormat.FontHeight = 8;
           
            // Adding new series
            IChartSeries series1 = charts.ChartData.Series.Add(fact1.GetCell(0, 0, 1, ""), charts.Type);
            //series1.Labels.DefaultDataLabelFormat.ShowLeaderLines = true;
            
            // Now populating series data
            int i = 1;
            foreach (var item in des)
            {
                series1.DataPoints.AddDataPointForPieSeries(fact1.GetCell(defaultWorksheetIndex1, i, 1, item.CategoryValue));
                i++;
            }
            // Not working in new version
            // Adding new points and setting sector color
            // series.IsColorVaried = true;
            charts.ChartData.SeriesGroups[0].IsColorVaried = true;
            int colorCount = 0;
            foreach (var item in des)
            {
                IChartDataPoint point = series1.DataPoints[colorCount];
                point.Format.Fill.FillType = FillType.Solid;
                point.Format.Fill.SolidFillColor.Color = System.Drawing.ColorTranslator.FromHtml(ColourValues[colorCount]);
                // Setting Sector border
                point.Format.Line.FillFormat.FillType = FillType.Solid;
                point.Format.Line.FillFormat.SolidFillColor.Color = System.Drawing.ColorTranslator.FromHtml(ColourValues[colorCount]);
                point.Format.Line.Width = 3.0;
                point.Format.Line.Style = LineStyle.Single;
                point.Format.Line.DashStyle = LineDashStyle.NotDefined;
                colorCount++;
            }
            // Create custom labels for each of categories for new series
            int LabelCount = 0;
            foreach (var item in des)
            {
                IDataLabel lbl1 = series1.DataPoints[LabelCount].Label;
                lbl1.DataLabelFormat.ShowPercentage = true;
                lbl1.DataLabelFormat.ShowCategoryName= true;
                lbl1.DataLabelFormat.TextFormat.PortionFormat.FontHeight = 8;
                // lbl1.DataLabelFormat.TextFormat.TextBlockFormat.AutofitType = true;
                
                LabelCount++;
            }
            // Write the presentation file to disk
            presentation.Save(path + "AnimatingCategoriesElements_out.pptx", SaveFormat.Pptx);
        }
        #endregion

@rajivyadav,

I have observed your comments. Can you please share presentation which are using in your sample code and generated result in form of presentation. Also Please provide complete working sample project that can be compiled and reproduces the issue. In source code you have provided are appeared unknown variables.