How to create a Formatted Table using Aspose.Slides?

Below is the sample C# code, which creates a formatted table. The output of the code is also attached.

C#

----------------------------------------------------------

//Get the first slide

Slide sld = pres.GetSlideByPosition(1);

//Create a table

Table tbl = sld.Shapes.AddTable(613, 486, 1453, 1, 4, 2,1,Color.Black);

//Headings for first row's columns

string[] headings ={"No.", "Word", "Count", "Ratio" };

//Iterate the first row cells

for (int i = 0; i < tbl.ColumnsNumber; i++)

{

//Get the cell of first row

Cell cell=tbl.GetCell(i, 0);

//Get its textframe, paragraph and portion

TextFrame tf=cell.TextFrame;

Paragraph para=tf.Paragraphs[0];

Portion port = para.Portions[0];

//Center align the text inside the paragrah

para.Alignment = TextAlignment.Center;

//Set the text formatting and text

port.FontHeight = 8;

port.FontBold = true;

port.Text = headings[i];

//Set the background color of cells

cell.FillFormat.Type = FillType.Solid;

cell.FillFormat.ForeColor = Color.FromArgb(0xff, 0xe5, 0xeb, 0xf5);

}//end for

//tbl.SetRowHeight(0,136);

//Background colors for cells in second row

uint[] backColor ={ 0xfff8e5e5, 0xffffffff, 0xffffffff, 0xffffffff };

//Foreground colors for cells in second row

uint[] fontColor ={ 0xffff0000, 0xffff0000, 0xff000000, 0xffff0000 };

//Text for cells in second row

string[] cellText ={ "2", "Word2", "1,015", "51.5 %" };

//Iterate the second row cells

for (int i = 0; i < tbl.ColumnsNumber; i++)

{

//Get the cell of second row

Cell cell = tbl.GetCell(i, 1);

//Get its textframe, paragraph and portion

TextFrame tf = cell.TextFrame;

Paragraph para = tf.Paragraphs[0];

Portion port = para.Portions[0];

//Left align the text inside the paragrah

para.Alignment = TextAlignment.Left;

//Set the text formatting and text

port.FontHeight = 8;

port.FontColor = Color.FromArgb((int)fontColor[i]);

port.Text = cellText[i];

//Set the background color of cells

cell.FillFormat.Type = FillType.Solid;

cell.FillFormat.ForeColor = Color.FromArgb((int)backColor[i]);

//Setting borders invisible

IEnumerator IEnum=cell.BorderLeft.GetEnumerator();

IEnum.MoveNext();

((Line)IEnum.Current).LineFormat.ForeColor = Color.FromArgb(0, 255, 0, 0);

//Setting borders invisible

IEnum = cell.BorderRight.GetEnumerator();

IEnum.MoveNext();

((Line)IEnum.Current).LineFormat.ForeColor = Color.FromArgb(0, 255, 0, 0);

}//end for

//Write presentation on disk

pres.Write("c:\\FormattedTable.ppt");

Hi,Shakeel Faiz

Thank you so much for quick reply.
I am going to check the code you wrote anyway.

Thank you,
Kaz