Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Nov 13, 2020 4:21 pm

Hi,
I have a Table --> Rows --> Cells --> Texts in it PPT report.
Now, i want to change the text color of it. By default i am seeing RGB (51,51,51).
Please help me out in resolving this text color.
Thanks in advance.

This is my code.

for (int i = 0; i < dt.Rows.Count; i++)
{
for (int j = 0; j < dt.Columns.Count; j++)
{
//Fil the table with data
table[j,i].TextFrame.Text = dt.Rows[i][j].ToString();
//Set the font
table[j,i].TextFrame.Paragraphs[0].TextRanges[0].LatinFont = new TextFont("Arial");
table[j,i].TextFrame.Paragraphs[0].TextRanges[0].FontHeight = 10f;

}
}

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

Mon Nov 16, 2020 3:25 am

Hello,

Thanks for your inquiry.
Please refer to the following code snippet to set the text color of a table cell. If there are any questions, please provide your input file and your desired output for further investigation.
Code: Select all
                    table[j, i].TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
                    table[j, i].TextFrame.Paragraphs[0].TextRanges[0].Fill.SolidColor.Color = Color.FromArgb(255,0,0);


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Tue Nov 17, 2020 6:23 am

Thanks for your quick response.
Mean while i tried with below code and it works for me.
table[j,i].TextFrame.TextRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
table[j,i].TextFrame.TextRange.Fill.SolidColor.Color = Color.FromArgb(255, 0, 0);

And also, i tried with the solution provided by you, it also works. May i know whats the difference between both.

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

Tue Nov 17, 2020 10:06 am

Hello,

Thanks for your response.
Kindly note that the code you used can only set the text color of the first text range of the first paragraph in the table cell. If there are multiple paragraphs in the table cell, please refer to the following code to set the text color.
Code: Select all
            foreach (TextParagraph para in table[j, i].TextFrame.Paragraphs)
            {
                foreach (TextRange range in para.TextRanges)
                {
                    range.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;

                    range.Fill.SolidColor.Color = Color.FromArgb(255, 0, 0);
                }
            }



Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF

cron