Textinfo problem in table

Hi
I would like to change color in every row of the table, which is not the problem. But the last coloumn of the table must be right aligned.
Problem: The textinfo that sets this ‘rightalign’ overwrites colorinfo of the last coloumn.

Thanks for your help

Gunther

TextInfo tinfo3 = new TextInfo();
TextInfo tinfo2 = null;

foreach (DataRow Row in Overview.ds.Tables[0].Rows)
{
i++;

Row newrow = table1.Rows.Add();

newrow.Cells.Add(Row[0].ToString());
newrow.Cells.Add(Row[1].ToString());
newrow.Cells.Add(Convert.ToString( Convert.ToInt32(Row[2]) / 60 ));

if (i%2 == 0)
{
tinfo3.BackgroundColor = new Aspose.Pdf.Color( “#ffffff” );
}

else
{
tinfo3.BackgroundColor = new Aspose.Pdf.Color( “#ffffcc” );
}

table1.RowsIdea.DefaultCellTextInfo = tinfo3;

tinfo2 = tinfo3.Clone() as TextInfo;
tinfo2.Alignment = AlignmentType.Right;
table1.SetColumnTextInfo( 2 , tinfo2 );
}

Hi,

Thank you for considering Aspose.

Please refer to SettingRowAndColumnFormat in the programmer’s guide.

Sorry but this doesn’t help very much. Your Example was the base for my code.
if (i%2 == 0)
{
tinfo3.BackgroundColor = new Aspose.Pdf.Color( “#ffffcc” );
}

else
{
tinfo3.BackgroundColor = new Aspose.Pdf.Color( “#ffffff” );
}
In the above codelines I switch the color.

table1.RowsIdea.DefaultCellTextInfo = tinfo3; // this line colors the tableline

tinfo2 = tinfo3.Clone() as TextInfo; // creating a clone of tinfo 3 results in color #ffffcc
tinfo2.Alignment = AlignmentType.Right;
table1.SetColumnTextInfo( 2 , tinfo2 );

the coloring of the table is ok, but the last coloumn always has the same color. I can change the lines in the if/else statement so the resulting color is changed. This indicates me that ‘cloning’ of cell 3 works, but only one loop, then the color is fix. Can you tell me why?

Thanks Gunther

Dear Gunther,

Thank you for considering Aspose.

I think you should set the column format of the last column after setting color of all cells. That means the
table1.SetColumnTextInfo( 2 , tinfo2 );
should be out of the foreach block.

If it still won’t work, please send me a complete runable example and let me test it.

Sorry, your suggestion doesn’t make any differense. The ‘rightaligning’ of the last coloumn destroys the colouring of the table. I hope you can reproduce the problem. I attached some code.

Thanks Gunther

Dear Gunther,

Thank you for considering Aspose.

I have reproduceed this problem. It seems the API is not flexible enough. The SetColumnTextInfo method will change text format for all cells in the column and text format of all cells will be set to the same. I need to improve the imterface later. As a work around, you can use Text paragraph alignment like the following:
// tinfo2 = tinfo3.Clone() as TextInfo;
// tinfo2.Alignment = AlignmentType.Right;
// table1.SetColumnTextInfo( 2 , tinfo2 );
Text t = row1.Cells[2].Paragraphs[0] as Text;
t.TextInfo.Alignment = AlignmentType.Right;