Why doesn't this code format my table?

I have the following code, I’m trying everything to format it but it still comes up in the DEFAULT Red with a large font. What am I doing wrong?

thanks again

int j = 0; // ROW
foreach(RowEx r in newTable.Rows)
{
for (int i = 0; i < 6; i++)
{
CellEx c = r[i];
c.BorderRight.FillFormat.FillType = FillTypeEx.Solid;
c.BorderRight.FillFormat.SolidFillColor.Color = Color.Gray;
c.BorderTop.Width = 1;
c.BorderBottom.Width = 1;
c.BorderLeft.Width = 1;
c.BorderRight.Width = 1;
c.TextFrame.Paragraphs[0].Portions[0].PortionFormat.LatinFont = new FontDataEx(“Arial”);
c.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 9;

TextFrameEx tfex = c.TextFrame;
// tfex.Paragraphs[0].Portions[0].Text = "Cell no " + (j ) + " " + (i);
tfex.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 9;
tfex.Paragraphs[0].Portions[0].PortionFormat.LatinFont = new FontDataEx(“Arial”);

// Columns
if (i == 0 && j > 0)
{
tfex.Paragraphs[0].Portions[0].Text = lstGPD[j - 1].MaterialCategoryName;
}
else if (i == 1 && j > 0)
{
tfex.Paragraphs[0].Portions[0].Text = lstGPD[j - 1].MaterialName;
}
else if (i == 2 && j > 0)
{
tfex.Paragraphs[0].Portions[0].Text = lstGPD[j - 1].Mass.ToString();
}
else if (i == 3 && j > 0)
{
tfex.Paragraphs[0].Portions[0].Text = lstGPD[j - 1].UnitName;
}
else if (i == 4 && j > 0)
{
tfex.Paragraphs[0].Portions[0].Text = Math.Round(GreenPrintCalculations.Convert_To_GSM(lstGPD[j - 1]),6).ToString();
}
else if (i == 5 && j > 0)
{
tfex.Paragraphs[0].Portions[0].Text = lstGPD[j - 1].Material.Reference;
}


// Row 0 HEADINGs
if (j == 0)
{
if (i == 0)
{
if (_baseline)
tfex.Paragraphs[0].Portions[0].Text = “Baseline”;
else
tfex.Paragraphs[0].Portions[0].Text = “Redesigned”;
}
else if (i == 1)
{
tfex.Paragraphs[0].Portions[0].Text = “Material Type”;
}
else if (i == 2)
{
tfex.Paragraphs[0].Portions[0].Text = “Mass/Density”;
}
else if (i == 3)
{
tfex.Paragraphs[0].Portions[0].Text = “Unit”;
}
else if (i == 4)
{
tfex.Paragraphs[0].Portions[0].Text = “gsm”;
}
else if (i == 5)
{
tfex.Paragraphs[0].Portions[0].Text = “Data Reference”;
}
}

}

foreach (CellEx cell in r)
{
cell.TextFrame.Paragraphs[0].Portions[0].PortionFormat.LatinFont = new FontDataEx(“Arial”);
cell.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 9;


cell.BorderTop.FillFormat.FillType = FillTypeEx.Solid;
cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Gray;
cell.BorderTop.Width = 1;

cell.BorderBottom.FillFormat.FillType = FillTypeEx.Solid;
cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Gray;
cell.BorderBottom.Width = 1;

cell.BorderLeft.FillFormat.FillType = FillTypeEx.Solid;
cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Gray;
cell.BorderLeft.Width = 1;

cell.BorderRight.FillFormat.FillType = FillTypeEx.Solid;
cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Gray;
cell.BorderRight.Width = 1;
}



j++;
}

}

Hi Jon,


I have worked with the code snippet shared by you using Aspose.Slides for .NET 6.0.0 on my end. I have not observed any default red large font effect. Please use the specified version of Aspose.Slides for .NET on your end. I have also attached the output presentation as well for your kind reference. The only modification that I made is that I assigned text paragraphs my self as I was missing the data from your end. Please share, if I may help you further.

//Instantiate PresentationEx class that represents PPTX file
PresentationEx pres = new PresentationEx();
//Access first slide
SlideEx sld = pres.Slides[0];
//Define columns with widths and rows with heights
double[] dblCols = { 50, 50, 50, 50, 50, 50 };
double[] dblRows = { 50, 30, 30, 30 };
//Add table shape to slide
int idx = sld.Shapes.AddTable(100, 50, dblCols, dblRows);
TableEx newTable = (TableEx)sld.Shapes[idx];
/////////
int j = 0; // ROW
bool _baseline = true;
foreach(RowEx r in newTable.Rows)
{
for (int i = 0; i < 6; i++)
{
CellEx c = r[i];

c.BorderRight.FillFormat.FillType = FillTypeEx.Solid;
c.BorderRight.FillFormat.SolidFillColor.Color = Color.Gray;
c.BorderTop.Width = 1;
c.BorderBottom.Width = 1;
c.BorderLeft.Width = 1;
c.BorderRight.Width = 1;
c.TextFrame.Paragraphs[0].Portions[0].PortionFormat.LatinFont = new FontDataEx(“Arial”);
c.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 9;
TextFrameEx tfex = c.TextFrame;
// tfex.Paragraphs[0].Portions[0].Text = "Cell no " + (j ) + " " + (i);
tfex.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 9;
tfex.Paragraphs[0].Portions[0].PortionFormat.LatinFont = new FontDataEx(“Arial”);
// Columns
if (i == 0 && j > 0)
{
tfex.Paragraphs[0].Portions[0].Text = “City”;// lstGPD[j - 1].MaterialCategoryName;
}
else if (i == 1 && j > 0)
{
tfex.Paragraphs[0].Portions[0].Text = “ISB”;// lstGPD[j - 1].MaterialName;
}
else if (i == 2 && j > 0)
{
tfex.Paragraphs[0].Portions[0].Text = “233”;// lstGPD[j - 1].Mass.ToString();
}
else if (i == 3 && j > 0)
{
tfex.Paragraphs[0].Portions[0].Text = “Asdaf”;/// lstGPD[j - 1].UnitName;
}
else if (i == 4 && j > 0)
{
tfex.Paragraphs[0].Portions[0].Text = “1234”;// Math.Round(GreenPrintCalculations.Convert_To_GSM(lstGPD[j - 1]), 6).ToString();
}
else if (i == 5 && j > 0)
{
tfex.Paragraphs[0].Portions[0].Text = “asdafasfasfad”;// lstGPD[j - 1].Material.Reference;
}
// Row 0 HEADINGs
if (j == 0)
{
if (i == 0)
{
if (_baseline)
tfex.Paragraphs[0].Portions[0].Text = “Baseline”;
else
tfex.Paragraphs[0].Portions[0].Text = “Redesigned”;
}
else if (i == 1)
{
tfex.Paragraphs[0].Portions[0].Text = “Material Type”;
}
else if (i == 2)
{
tfex.Paragraphs[0].Portions[0].Text = “Mass/Density”;
}
else if (i == 3)
{
tfex.Paragraphs[0].Portions[0].Text = “Unit”;
}
else if (i == 4)
{
tfex.Paragraphs[0].Portions[0].Text = “gsm”;
}
else if (i == 5)
{
tfex.Paragraphs[0].Portions[0].Text = “Data Reference”;
}
}
}
foreach (CellEx cell in r)
{

cell.TextFrame.Paragraphs[0].Portions[0].PortionFormat.LatinFont = new FontDataEx(“Arial”);
cell.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 9;

cell.BorderTop.FillFormat.FillType = FillTypeEx.Solid;
cell.BorderTop.FillFormat.SolidFillColor.Color = Color.Gray;
cell.BorderTop.Width = 1;
cell.BorderBottom.FillFormat.FillType = FillTypeEx.Solid;
cell.BorderBottom.FillFormat.SolidFillColor.Color = Color.Gray;
cell.BorderBottom.Width = 1;
cell.BorderLeft.FillFormat.FillType = FillTypeEx.Solid;
cell.BorderLeft.FillFormat.SolidFillColor.Color = Color.Gray;
cell.BorderLeft.Width = 1;
cell.BorderRight.FillFormat.FillType = FillTypeEx.Solid;
cell.BorderRight.FillFormat.SolidFillColor.Color = Color.Gray;
cell.BorderRight.Width = 1;
}
j++;
}
pres.Write(“d:\Aspose Data\table.pptx”);


Many Thanks,

This is what I get using 5.6

None of the formating works

Hi Jon,


Please observe the shared presentation in my last post. I have generated that using the exact code snippet shared by you with Aspose.Slides for .NET 6.0.0. Please observe the generated presentation on your end and try using the specified version.

Many Thanks,