Font color Issue

I’m changing the color of the font in 2 separate rows and then switching back to the normal color. The problem is the 2nd row refuses to change it’s color over. Here’s my code…





if (counter == 0)

{

cell.BorderTop.FillFormat.FillType = FillType.Solid;

cell.BorderLeft.FillFormat.FillType = FillType.Solid;

cell.BorderRight.FillFormat.FillType = FillType.Solid;

cell.BorderBottom.FillFormat.FillType = FillType.Solid;

cell.BorderTop.FillFormat.SolidFillColor.Color = Color.White;

cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.White;

cell.BorderRight.FillFormat.SolidFillColor.Color = Color.White;

cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.White;

cell.FillFormat.SolidFillColor.Color = ColorTranslator.FromHtml("#6E6E6E");

port.PortionFormat.FillFormat.FillType = FillType.Solid;

port.PortionFormat.FillFormat.SolidFillColor.Color = Color.White;

cell.TextAnchorType = TextAnchorType.Bottom;

cell.BorderBottom.Width = 0;

cell.BorderTop.Width = 0;

cell.BorderLeft.Width = 0;

cell.BorderRight.Width = 0;

}



else if (counter == 1)

{

cell.BorderTop.FillFormat.FillType = FillType.Solid;

cell.BorderLeft.FillFormat.FillType = FillType.Solid;

cell.BorderRight.FillFormat.FillType = FillType.Solid;

cell.BorderBottom.FillFormat.FillType = FillType.Solid;

cell.BorderTop.FillFormat.SolidFillColor.Color = Color.White;

cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.White;

cell.BorderRight.FillFormat.SolidFillColor.Color = Color.White;

cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.White;

cell.FillFormat.SolidFillColor.Color = ColorTranslator.FromHtml("#F58000");



port.PortionFormat.FillFormat.FillType = FillType.Gradient;

port.PortionFormat.FillFormat.SolidFillColor.Color = Color.White;



cell.TextAnchorType = TextAnchorType.Bottom;

cell.BorderBottom.Width = 0;

cell.BorderTop.Width = 0;

cell.BorderLeft.Width = 0;

cell.BorderRight.Width = 0;

}

else

{



cell.BorderTop.FillFormat.FillType = FillType.NoFill;

cell.BorderLeft.FillFormat.FillType = FillType.NoFill;

cell.BorderRight.FillFormat.FillType = FillType.NoFill;

cell.BorderBottom.FillFormat.FillType = FillType.NoFill;

cell.BorderBottom.Width = 0;

cell.BorderTop.Width = 0;

cell.BorderLeft.Width = 0;

cell.BorderRight.Width = 0;



if ((counter % 2) == 0)

{

cell.FillFormat.SolidFillColor.Color = ColorTranslator.FromHtml("#D3D3D3");

}

else

{

cell.FillFormat.SolidFillColor.Color = Color.White;

}



}







The when the counter == 2 it does not change the font color to white. It stays black.

Hi Gilbert,

I have observed the sample code shared by you and request you to please provide the sample presentation, generated output and desired output. Please also share the working example with us that I may use on my end to help you further in this regard.

Many Thanks,

I’ve figured out the issue. Apparently the use of the variable “port” could only be used once. If instead I went with the longer definition for the color changes such as…





tf.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillType.Solid;

tf.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.White;





It will work. Please see my code above for the definition of “port”. This seems to be a bug within Aspose Slides itself.

Hi Gilbert,


I have observed the sample code shared by you and unfortunately have not been able to find definition of variable port in your sample code. As requested earlier, please share the working sample code along with generated presentation and desired output presentation. I will investigate the issue further on my end on the provision of requested information to help you out.

Many Thanks,

Hi Mudassir,



Unfortunately since this is corporate code I am unable to share it. Although my definition of port is as follows…







IPortion port = tf.Paragraphs[0].Portions[0];







In the code itself I have to call the portions via the full line of code…







tf.Paragraphs[0].Portions[0].(Whatever I’m trying to call)







That is the only way it’ll actually work instead of using the IPortion various times.

Hi Gilbert,


I have tried to generate the sample code on my end based on your code. I have not been able to observe the issue on my end. I have been able to properly set the portion text color. Please try using the following working sample on your end to verify the working. If there is still an issue then please share the working sample application along with generated and desired output presentation. I will try my best to help you further in this regard.

public static void TestTableIssue()
{

Presentation pres = new Presentation();

//Access first slide
ISlide sld = pres.Slides[0];

//Define columns with widths and rows with heights
double[] dblCols = { 50, 50, 50 };
double[] dblRows = { 50, 30, 30, 30, 30 };

//Add table shape to slide
ITable tbl = sld.Shapes.AddTable(100, 50, dblCols, dblRows);

IPortion port = null;
ITextFrame tf = null;
int counter = 0;
//Set border format for each cell
foreach (IRow row in tbl.Rows)
foreach (ICell cell in row)
{
cell.BorderTop.FillFormat.FillType = FillType.Solid;
cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderTop.Width = 5;

cell.BorderBottom.FillFormat.FillType = FillType.Solid;
cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderBottom.Width = 5;

cell.BorderLeft.FillFormat.FillType = FillType.Solid;
cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderLeft.Width = 5;

cell.BorderRight.FillFormat.FillType = FillType.Solid;
cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Red;
cell.BorderRight.Width = 5;
// }
tf = cell.TextFrame;

port = tf.Paragraphs[0].Portions[0];

if (counter == 0)
{
cell.BorderTop.FillFormat.FillType = FillType.Solid;
cell.BorderLeft.FillFormat.FillType = FillType.Solid;
cell.BorderRight.FillFormat.FillType = FillType.Solid;
cell.BorderBottom.FillFormat.FillType = FillType.Solid;
cell.BorderTop.FillFormat.SolidFillColor.Color = Color.White;
cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.White;
cell.BorderRight.FillFormat.SolidFillColor.Color = Color.White;
cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.White;
cell.FillFormat.SolidFillColor.Color = ColorTranslator.FromHtml("#6E6E6E");
port.PortionFormat.FillFormat.FillType = FillType.Solid;
port.PortionFormat.FillFormat.SolidFillColor.Color = Color.White;
cell.TextAnchorType = TextAnchorType.Bottom;
cell.BorderBottom.Width = 0;
cell.BorderTop.Width = 0;
cell.BorderLeft.Width = 0;
cell.BorderRight.Width = 0;
}

else if (counter == 1)
{
cell.BorderTop.FillFormat.FillType = FillType.Solid;
cell.BorderLeft.FillFormat.FillType = FillType.Solid;
cell.BorderRight.FillFormat.FillType = FillType.Solid;
cell.BorderBottom.FillFormat.FillType = FillType.Solid;
cell.BorderTop.FillFormat.SolidFillColor.Color = Color.White;
cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.White;
cell.BorderRight.FillFormat.SolidFillColor.Color = Color.White;
cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.White;
cell.FillFormat.SolidFillColor.Color = ColorTranslator.FromHtml("#F58000");

port.PortionFormat.FillFormat.FillType = FillType.Gradient;
port.PortionFormat.FillFormat.SolidFillColor.Color = Color.White;

cell.TextAnchorType = TextAnchorType.Bottom;
cell.BorderBottom.Width = 0;
cell.BorderTop.Width = 0;
cell.BorderLeft.Width = 0;
cell.BorderRight.Width = 0;

port.Text = “Test 1”;
}
else
{

cell.BorderTop.FillFormat.FillType = FillType.NoFill;
cell.BorderLeft.FillFormat.FillType = FillType.NoFill;
cell.BorderRight.FillFormat.FillType = FillType.NoFill;
cell.BorderBottom.FillFormat.FillType = FillType.NoFill;
cell.BorderBottom.Width = 0;
cell.BorderTop.Width = 0;
cell.BorderLeft.Width = 0;
cell.BorderRight.Width = 0;

if ((counter % 2) == 0)
{
cell.FillFormat.SolidFillColor.Color = ColorTranslator.FromHtml("#D3D3D3");
port.Text = “Test 2”;
}
else
{
cell.FillFormat.SolidFillColor.Color = Color.White;
port.Text = “Test 3”;
}
}
counter++;
}
pres.Save(“C:\Presentations\TestData.pptx”, SaveFormat.Pptx);

}

Many Thanks,