We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Use of PPTX template

Hi,

Do we have provision to use PPTX template which will contain structure of table and data header and data marker field in slide. and we have to give data source to that table to populate data.

Thanks,

Prasad

Hi Prasad,

Thanks for inquiring Aspose.Slides.

I have observed your requirement of setting data source for table and regret to share that you need to fill the table your self by inserting rows and filling the rows cells with data. There is no automated way available to set the data source for the table. Please share, if I may help you further in this regard.

Many Thanks,

Thanks Mudassir for reply.

--Prasad

Hi,

My Another question is, i have created sample chart and if i right click on chart and click on "Edit Data". then i am not able to see data in Excel (usually if we edit chart data with values gets open in Excel workbook.). is this because i have evaluation version? or we are not having this feature.

Please let me know if you need any clarification on my question.

Reference snapshot attached.

Thanks,

Prasad

Hi Prasad,

I have observed the snapshot and like to share that this issue has been resolved in Aspose.Slides for .NET 14.10.0 for some charts. I suggest you to please try using the specified version on your end. If there is still an issue then please share the sample application, source presentation and generated presentation files with us. I will investigate the issue on my end to help you further in this regard.

Many Thanks,

Hi Mudassir,

I am using 14.10.0 version only. and trying with the simple chart. please look at below code and i have searched to remove axes major grid but not able to found any option for that. please let me know the solution for edit data and remove mojor grid.

Thanks,

Prasad

// Create directory if it is not already present.

bool IsExists = System.IO.Directory.Exists(dataDir);

if (!IsExists)

System.IO.Directory.CreateDirectory(dataDir);

//Instantiate Presentation class that represents PPTX file

Presentation pres = new Presentation();

//Access first slide

ISlide sld = pres.Slides[0];

// Add chart with default data

IChart chart = sld.Shapes.AddChart(ChartType.PercentsStackedBar, 0, 0, 500, 500);

//Setting chart Title

//chart.ChartTitle.TextFrameForOverriding.Text = "Sample Title";

chart.ChartTitle.AddTextFrameForOverriding("Sample Title");

chart.ChartTitle.TextFrameForOverriding.TextFrameFormat.CenterText = NullableBool.True;

chart.ChartTitle.Height = 20;

chart.HasTitle = true;

//Set first series to Show Values

chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowValue = true;

//Setting the index of chart data sheet

int defaultWorksheetIndex = 0;

//Getting the chart data worksheet

IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;

//Delete default generated series and categories

chart.ChartData.Series.Clear();

chart.ChartData.Categories.Clear();

int s = chart.ChartData.Series.Count;

s = chart.ChartData.Categories.Count;

//Adding new series

chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, "Series 1"), chart.Type);

chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, "Series 2"), chart.Type);

//Adding new categories

chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1"));

chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2"));

chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3"));

//Take first chart series

IChartSeries series = chart.ChartData.Series[0];

//Now populating series data

series.ParentSeriesGroup.Overlap = 100;

series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 20));

series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 50));

series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30));

//Setting fill color for series

series.Format.Fill.FillType = FillType.Solid;

series.Format.Fill.SolidFillColor.Color = Color.Red;

//Take second chart series

series = chart.ChartData.Series[1];

//Now populating series data

series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 2, 30));

series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 2, 10));

series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 2, 60));

//Setting fill color for series

series.Format.Fill.FillType = FillType.Solid;

series.Format.Fill.SolidFillColor.Color = Color.Green;

//first label will be show Category name

IDataLabel lbl = series.DataPoints[0].Label;

lbl.DataLabelFormat.ShowCategoryName = true;

lbl = series.DataPoints[1].Label;

lbl.DataLabelFormat.ShowSeriesName = true;

//Show value for third label

lbl = series.DataPoints[2].Label;

lbl.DataLabelFormat.ShowValue = true;

lbl.DataLabelFormat.ShowSeriesName = true;

lbl.DataLabelFormat.Separator = "/";

//Save presentation with chart

pres.Save(dataDir + "/AsposeChart.pptx", SaveFormat.Pptx);

Hi Prasad,

Thank you for sharing the details with us. I have been able to observe the issue in generated presentation and a ticket with ID SLIDESNET-36059 has been created in our issue tracking system to investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,

Please assist with removing major grid line in. (horizontal axis major gridlines)

Thanks,

Prasad

Hi Prasad,

Please try using the following sample code on your end to serve the purpose.

//Setting Major grid lines format for value axis
chart.Axes.VerticalAxis.MajorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;

//Setting Minor grid lines format for value axis
chart.Axes.VerticalAxis.MinorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;

//Setting Major grid lines format for value axis
chart.Axes.HorizontalAxis.MajorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;

//Setting Minor grid lines format for value axis
chart.Axes.HorizontalAxis.MinorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;


Many Thanks,

Hi Mudassir,


We want to add a benchmark value in chart for each category.
Please assist.
Screenshot is attached.

Thanks in advance.

Prasad

Hi Prasad,

I have observed your requirements and like to share there is no such option of setting benchmark value for chart data in PowerPoint as per my understanding. If there is any mechanism available in charts to do that then please share that with us and we will investigate that on our end. The one option that is available is to try using and fitting chart trend lines features in your approach if that is workable on your end. The requested support is unavailable in Aspose.Slides. Please share the details about setting benchmark values inside chart and we will try to help you further in this regard.

Many Thanks,

Hi Mudassir,

1. We will be having percentage value to draw a vertical line on percentage chart. (i.e. percentage value would be 40% then on chart there will be a vertical line at 40% points) snapshot attached. Advice on this.

2. I am getting integer values from database to draw a percentage chart and i want to show data label as "57%". And want to set font height as 10 but when we override 57 with "57%" then font size is not changing. Please observe attachments.

code:

IDataLabel lbl = series.DataPoints[1].Label;

lbl.TextFormat.PortionFormat.FontHeight = 10;

lbl.AddTextFrameForOverriding(Convert.ToString(dt.Rows[i]["Percentage"]) + "%");

Thanks,

Prasad

Hi Prasad,

For point 1 concerning to calculating the percentage, I regret to share that there is no direct property available to identify this. However, you can calculate the percentage for category values. For this, you need to get the total sum by adding all the concerned series values used in desired chart category. Then you can divide individual series values inside the desired category with total sum *100. Please visit this thread link for your reference and to develop logic on your end.

For your second query concerning to setting the custom text format. Please try using the following sample code on your end. I hope this will be helpful. Please share, if I may help you further in this regard.

lbl = series.DataPoints[1].Label;
lbl.AddTextFrameForOverriding("");
lbl.TextFrameForOverriding.Paragraphs[0].Portions[0].Text = Convert.ToString(dt.Rows[i][“Percentage”]) + “%”;
lbl.TextFrameForOverriding.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 10;

Many Thanks,

Hi Mudassir,


Below is my business requirement.
I will be having data from database which will contain
1.Section (Heading)
2.Subsection (Sub Heading)
3.Subsection 2(Sub Heading 2)
3.year (Category)
4.Response (Series)
Chart will be the percentage stacked bar chart. and at a time depending on parameter multiple slides we want to generate (lets say 100 slides. which will have multiple charts).
and we have to place that each chart on slide.

so there are some questions i have and some suggestions i want to implement this thing using aspose slide.

1. Is there any way to avoid setting up the co-ordination for each chart ( as i am placing each chart on slide by setting there x and y co-ordinate along with there height and width).

2. is there any table structure available to put charts in aligned manner. (i will be creating one table in slide and adding chart in particular cell lets say 3 charts per slide).

3. Every chart will be produced through for loop so any suggestion to add slide dynamically and arrange all Charts. so that formation of chart will be structured.

Please assist on the above scenarios. and let me know if you need any additional details on this.

Thanks,
Prasad

Hi Prasad,


I have observed your requirement and if I sum up, you actually wish to add two or three charts per slide and want to organize them in slide. Right?. In this scenario, you can easily manage the things. Let me share some rough logic with you that you can employ on your end to get the desired results. The default presentation height is 540 usually. So you need to add charts in slide whose collective height + offset between charts must not be greater than slide height. For example, if you ought to add three charts per slide then you may set the height of chart 170. So 170 * 3=510 and let 10 be the offsets between charts. So collectively it will become 540. The following sample code exhibits the exact logic that I am trying to explain and I am hopeful, it will help you. As far as adding chart inside table is concerned, I am afraid this in not even possible in PowerPoint to add chart inside table cell.

public static void addCharts()
{
Presentation pres = new Presentation();

int number_of_Charts = 11;
int iOffsetbetweenCharts = 10;

ISlide slide = pres.Slides[0]; ;

float iChartHeight = (pres.SlideSize.Size.Height - iOffsetbetweenCharts3) / 3;//-30 to set offset between charts
float iChartWidth = 300;//Any value you want to set

float iChartXPosition = 50;
float iChartYPosition = iOffsetbetweenCharts;//First chart Y position

int iChartCountPerSlide = 1;
for (int i = 0; i < number_of_Charts; i++)
{
IChart chart=slide.Shapes.AddChart(ChartType.ClusteredBar,iChartXPosition,iChartYPosition,iChartWidth,iChartHeight);

iChartYPosition =iChartCountPerSlide iChartHeight + iOffsetbetweenCharts;

iChartCountPerSlide++;

if(i>0 && (i+1) % 3==0)// After every 3 slides add new slide in collection
{
slide=pres.Slides.AddEmptySlide(pres.LayoutSlides.GetByType(SlideLayoutType.Blank));
//Reset the chart height
iChartYPosition = iOffsetbetweenCharts;
iChartCountPerSlide = 1;
}

}

pres.Save(“C:\Presentations\TestChart.pptx”,SaveFormat.Pptx);

}

Many Thanks,

1.Can we reduce space between two chart bars? (refer above chart)?

2.Is there any way to add multiple charts without legends and add legend at the bottom of the slide?

3. i will be having different count of chart for each slide. and some charts will have multiple charts series and categories (want this in loop). please share the sample code.

Thanks,

Prasad

Hi Prasad,

I have observed your requirements and like to share that you can show hide the legends and can also set their position if the are shown. The following lines of code responsible for setting legend visibility and position.

chart.HasLegend = true;//If false then legend will not be visible
chart.Legend.Position = LegendPositionType.Bottom;

Can you please share what actually you mean by space between two charts. Lastly, for point 3, I have shared the generic scheme for your convenience to place multiple charts aligned on one slide. You please now need to develop your own logic for making charts with multiple series and categories.

Many Thanks,

Hi,


We got license of Aspose API. :slight_smile:
We have some questions.
1. I am using chart type as StackedBar, but the data which I am putting into chart series is not occupying proper space. please find attached output(IMG1).eg. chart with 7% occupying 50% space.
2. Is there any property to get exact height of Series, please find marked section in attachment.

Thanks,
Prasad

Also please let me know how to get upper and lower spacing in chart?


Thanks,
Praad

Hi Prasad,

Thank you for the details.

PrasadD:
1.
I am using chart type as StackedBar, but the data which I am putting
into chart series is not occupying proper space. please find attached
output(IMG1).eg. chart with 7% occupying 50% space.


Please share the sample code and generated file with us to help us reproduce the issue at our end. We will check it and get back to you.

PrasadD:

2. Is there any property to get exact height of Series, please find marked section in attachment.


I am afraid, this feature is not available in Aspose.Slides and also, it is not available in MS PowerPoint.

PrasadD:

Also please let me know how to get upper and lower spacing in chart?


Please provide some more details, preferably with some sample to help us understand your requirement. We will check it and provide you a solution accordingly.

Thanks & Regards,