We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

3 different items text above table in slide, font size of text in table cell, adding chart from database

I am working on creating a presentation.

1)    I want to be able to list some text above the table in the 2nd slide but it is moving it to the 1st slide.  It is the text Attitudes & Perceptions which you can see listed in the first slide of the attached power point even though i am showing it as being added to the 2nd slide.  How do I do this so that it is shown in the same slide as the table?     

2)  I want to use a much smaller font in the table.  I cannot find anything on setting font size in a cell 

3)  I need to then display a slide with a chart  but cannot see how to get data from the database to create the chart.  I cannot use the import from Excel method and cannot import data at build time.   is this possible?   

Attachment: PowerpointController_7601b354.zip

5 Replies

KK Kumaravel Kulandai Samy Syncfusion Team September 7, 2017 08:06 AM UTC

Hi Miranda, 
We have checked the provided sample. In the sample, the “Group1Text” is set to shape of the first slide. The “Group1Text” should be set the paragraph of the second slide to achieve your expected output. 
 
Please find the modified code snippet below 
 
Please find the code snippet to change the font size inside the cell is as below: 
ITextPart text = cell.TextBody.Paragraphs[index].TextParts[index]; 
text.Font.FontSize = 10; 
 
For example:To get the font size from the “TextPart” of the  first paragraph 
 
ITextPart text = cell.TextBody.Paragraphs[0].TextParts[0]; 
text.Font.FontSize = 10; 



Scenario 
Sample 
Output 
1.The text “Attitudes & Perceptions” in the second slide above the table 
2.Changing the size of the text in each cell.  
 
 
 
 
Create chart in presentation using the database in Excel sheet: 
 
 

Please let us know if you need any further assistance on this. 
Regards, 
Kumaravel.K 




MJ Miranda Johnson replied to Kumaravel Kulandai Samy September 7, 2017 02:58 PM UTC

Hi Miranda, 
We have checked the provided sample. In the sample, the “Group1Text” is set to shape of the first slide. The “Group1Text” should be set the paragraph of the second slide to achieve your expected output. 
 
Please find the modified code snippet below 
 
Please find the code snippet to change the font size inside the cell is as below: 
ITextPart text = cell.TextBody.Paragraphs[index].TextParts[index]; 
text.Font.FontSize = 10; 
 
For example:To get the font size from the “TextPart” of the  first paragraph 
 
ITextPart text = cell.TextBody.Paragraphs[0].TextParts[0]; 
text.Font.FontSize = 10; 



Scenario 
Sample 
Output 
1.The text “Attitudes & Perceptions” in the second slide above the table 
2.Changing the size of the text in each cell.  
 
 
 
 
Create chart in presentation using the database in Excel sheet: 
 
 

Please let us know if you need any further assistance on this. 
Regards, 
Kumaravel.K 



From your sample for getting the data is pulling from Excel the only option other than entering it at design time?   Is there any way to get the data from my database via the data access layer?     If I must go the excel route I will find a way for the user to upload their file into the system.   However, I noticed that you entered the  data range on the spreadsheet  what about dynamic data where the programmer does not know the range beforehand?  


 



KK Kumaravel Kulandai Samy Syncfusion Team September 11, 2017 09:42 AM UTC

Hi Miranda, 
Please find the details below. 
Is there any way to get the data from my database via the data access layer? 
Yes, the data can be exported to a DataTable from a data base and then we can create an excel file from DataTable. We have created a sample for this and attached in below link. 
In this sample, 
1.       We have used an XML file as a DataBase 
2.       We have exported the data from XML file to a DataTable 
3.       Populated the data in DataTable to an excel file 
4.       We have created the chart from that excel file. The data range in the excel file is obtained dynamically from the excel file. 
Noticed that you entered the data range on the spreadsheet what about dynamic data where the programmer does not know the range beforehand?  
We can dynamically get the data range in the excel file, using the below code snippet. We have used this API in the above attached sample. 
 
worksheet.UsedRangeIncludesFormatting = false;  
Var Value=worksheet.usedRange;  
 
 

Please let us know if you need any further assistance on this. 
Regards, 
Kumaravel 




MJ Miranda Johnson September 11, 2017 11:01 PM UTC

Thank you.   Now I have some more questions.   

  1. I want my chart to show from 0 to 5 where in the attached Powerpoint it is showing from 3.9 to 4.8   I have not found anything in the API that references how I set that.(see attached image)
  2. I would like to have the words Average Answer under the chart like is show on the attached image.  
  3. My next issue is in creating the 2nd chart.   This can actually have up to 18 different charts on it but I have not gotten the 2nd one to work yet.  I believe I am referencing the correct worksheet (name Q4  index 3)   I get no errors at build  and none when I run, but when I try to open it says Powerpoint was unable to display some of the text, images or objects because they have become corrupted.  
  4. lastly is it possible to have different colors in the charts based on the score 0-1 = red,1-2 = orange,2-3 = yellow ,3-4 = teal,4-5 = green  


Attachment: PowerpointController_71312183.zip


KK Kumaravel Kulandai Samy Syncfusion Team September 14, 2017 10:12 AM UTC

Hi Miranda, 
Please find the details below, 
I want my chart to show from 0 to 5 where in the attached Powerpoint it is showing from 3.9 to 4.8   I have not found anything in the API that references how I set that. 
You must set the primary Value Axis minimum value to zero as below. 
chart.PrimaryValueAxis.MinimumValue = 0; 
 
I would like to have the words Average Answer under the chart like is show on the attached image.   
 
You must set the PrimaryValue Axis Title to achieve this 
  chart.PrimaryValueAxis.Title = "Average Answer";     
 
My next issue is in creating the 2nd chart.   This can have up to 18 different charts on it but I have not gotten the 2nd one to work yet.  I believe I am referencing the correct worksheet (name Q4 index 3)   I get no errors at build and none when I run, but when I try to open it says PowerPoint was unable to display some of the text, images or objects because they have become corrupted.   
 
We have checked this. But we cannot reproduce the issue at our end. We have attached the sample that we tried to reproduce the issue at our end. 
 
Sample:  
 
Screenshot of the generated document 
 
lastly is it possible to have different colors in the charts based on the score 0-1 = red,1-2 = orange,2-3 = yellow ,3-4 = teal,4-5 = green   
 
In the provided worksheet, you have only one data range values. As per Microsoft office documents behavior we cannot set different color for the single data range value.  
 
 
 
If you have multiple data range value then you can set different color as you mentioned in your scenario 
 
 
 
If you want to set the different color for series use the following code snippet: 
 
       
serie1.SerieFormat.Fill.ForeColor = Color.Aqua; 
                  (or) 
serie.SerieFormat.Fill.ForeColor = Color.FromArgb(91, 155, 213); 
 
 
 

Please let us know if you need any further assistance in this. 
Regards, 
Kumaravel.K 


Loader.
Up arrow icon