How to set horizontal alignment for the text in table on presentation slides

With the help of Spire.Presentation, developers can set the horizontal alignment for the text on presentation slides easily. This article will focus on show you how to set the horizontal alignment for the text on the table of the presentation slides in C#. There are five options for the text alignment on the Spire.Presentation: Left, Right, Center, Justify and None.

At first, please check a document with default alignment (Left) prepared. Then, different alignment styles will be applied for the different rows on the table.

How to set vertical alignment for the text in table on presentation slides

Step 1: Create a presentation document and load the sample document from file.

Presentation presentation = new Presentation();
presentation.LoadFromFile("Sample.pptx",FileFormat.Pptx2010);

Step 2: Get the table from the sample document.

ITable table = null;

foreach (IShape shape in presentation.Slides[0].Shapes)
{
    if (shape is ITable)
    {
        table = (ITable)shape;

Step 3: Align text horizontally.

for (int i = 0; i < table.ColumnsList.Count; i++)
{
   
    table[i, 0].TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Right;
    table[i, 1].TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Center;
    table[i, 2].TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Left;
    table[i, 3].TextFrame.Paragraphs[0].Alignment = TextAlignmentType.None;
    table[i, 4].TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Justify;

}

Step 4: Save the document to file.

presentation.SaveToFile("tableresult.pptx", FileFormat.Pptx2010);

Effective screenshot after apply the horizontal alignment for the text on table:

How to set vertical alignment for the text in table on presentation slides

Full codes of how to set horizontal alignment for the text on the presentation slide's table:

static void Main(string[] args)
{
        
        Presentation presentation = new Presentation();
        presentation.LoadFromFile("Sample.pptx",FileFormat.Pptx2010);

        ITable table = null;

        foreach (IShape shape in presentation.Slides[0].Shapes)
        {
            if (shape is ITable)
            {
                table = (ITable)shape;

                for (int i = 0; i < table.ColumnsList.Count; i++)
                {
                   
                    table[i, 0].TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Right;
                    table[i, 1].TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Center;
                    table[i, 2].TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Left;
                    table[i, 3].TextFrame.Paragraphs[0].Alignment = TextAlignmentType.None;
                    table[i, 4].TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Justify;

                
                }
            }
        }
        presentation.SaveToFile("tableresult.pptx", FileFormat.Pptx2010);
    }