Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Sun Mar 07, 2021 9:33 am

Hi Team,

I'm Trying to add Font size to each row cell in my data table, but the applied font size is not binding if binding row cell by adding a new line in it.

I would like to apply font size to each row cell even if my row cell have a concatenation of multiple text or binding Title and in new line bind address1, address2 ect.,

Attached screen shot for reference on how it looks likes in presentation file.

Thanks in advance for your support.
Here is my code.

DataTable dt = new DataTable
dt.Columns.Add();
dt.Columns.Add();

dt.Rows.Add("About", "Age");

for(int i=0; i < listValues.Count ; i++){
string concatinateValue = listValues.Name + System.Environment.NewLine + listValues.Address1 + ", " + listValues.Address2;
dt.Rows.Add(concatinateValue, listValues.Age)
}

ITable table = ppt.Slides[0].Shapes.AppendTable(ppt.SlideSize.Size.Width /2 - 380, 185, widths, heights);
for(int i = 0; i< dt.Rows.Count ; i++){
for(int j=0; j < dt.Columns.Count; j++){
table[j,i].TextFrame.Text = dtConsequence.Rows[i][j].ToString();
//Set the font
table[j,i].TextFrame.Paragraphs[0].TextRanges[0].LatinFont = new TextFont("MyFont");
table[j,i].TextFrame.Paragraphs[0].TextRanges[0].FontHeight = 9f;
table[j,i].TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
}
}

saleembaigmirza
 
Posts: 21
Joined: Fri Nov 13, 2020 4:15 pm

Sun Mar 07, 2021 9:41 am

In the above code, i have used as below
table[j,i].TextFrame.Paragraphs[0].TextRanges[0].FontHeight = 9f;

As per my expectations, it should apply font height as 9f to 'injury' text which is present in row cell and also it should apply the same height as 9f to 'desc1, string, string' which is present in same row cell. But this font height is not applying to the text which i prepared row cell by adding new line in it.

Please let me know for any clarifications.

Thanks in advance for your support.

saleembaigmirza
 
Posts: 21
Joined: Fri Nov 13, 2020 4:15 pm

Mon Mar 08, 2021 10:23 am

Hello,

Thanks for your inquiry.
According to the screenshot you provided, you should have added several paragraphs to the table cell, but you have only set the font size for the first paragraph. So the font size for the other paragraphs is still the default.
Please refer to the following code to set the font size for every paragraph. If there are any issues, please provide your desired PPTX file for our reference.
Code: Select all
                    for(int p=0;p < table[j, i].TextFrame.Paragraphs.Count; p++)
                    {
                        for(int t=0;t < table[j, i].TextFrame.Paragraphs[p].TextRanges.Count; t++)
                        {
                            table[j, i].TextFrame.Paragraphs[p].TextRanges[t].FontHeight = 9f;
                        }
                    }



Sincerely,
Elena
E-iceblue support team
User avatar

Elena.Zhang
 
Posts: 279
Joined: Thu Jul 23, 2020 1:18 am

Return to Spire.Presentation