How to create a Formatted Table using Aspose.Slides?

Last post 09-09-2008, 9:22 PM by Higa. 1 replies.
Sort Posts: Previous Next
  •  09-09-2008, 5:46 PM 143217

    How to create a Formatted Table using Aspose.Slides?

    Attachment: Present (inaccessible)

    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");


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Developer
    Aspose Sialkot Team
    Contact Us
    Aspose - The .NET and Java Component Publisher

    Keep in touch! We're on Twitter and Facebook
     
  •  09-09-2008, 9:22 PM 143233 in reply to 143217

    Re: How to create a Formatted Table using Aspose.Slides?

    Hi,Shakeel Faiz

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

    Thank you,
    Kaz

     
View as RSS news feed in XML