Hi, I would like to center align a table after it has been created, can this be done using aspose slides? Kind Regards
I have observed your requirement and it seems that you are probably looking for option to set the text alignment of contents inside the table cells to center. Please try using the following sample code on your end to serve the purpose.
public static void TestTableVertical()
Presentation pres = new Presentation(“d:\Aspose Data\Vertical.pptx”);
//Accessing a slide using its slide position
ISlide slide = pres.Slides ;;
for (int i = 0; i < slide.Shapes.Count; i++)
if (slide.Shapes[i] is ITable)
ITable tbl = (ITable)slide.Shapes[i]; ;
for (int j = 0; j < tbl.Rows.Count; j++)
for (int k = 0; k < tbl.Columns.Count; k++)
ICell cell = tbl[k, j];
ITextFrame tf = tbl[k, j].TextFrame;
tf.Paragraphs.ParagraphFormat.Alignment = TextAlignment.Center;
tf.Text = “Welcome”;
Hi Mudassir, thank you for the quick reply! However I am wanting to align the table for example I am using Microsoft Powerpoint 2013 and if you select the table you are working with - goto Layout tab, you can click on “Align” and have options on how to choose how to align your table e.g “Align Left”, “Align Right”. I ask this because there is a requirement from a client wanting tables center aligned. Hope you can help. Thanks again.
Thanks for your further elaboration. I have verified from PowerPoint that when you set the alignment either to left, right or center on table level, it gets set for every cell inside the table. On back end, even MS PowerPoint sets the alignment of each cell to selected alignment individually. You do the same using Aspose.Slides and the code sample shared in my last post iterates through every cell and sets the alignment of the cell to selected one. I hope this will clarify the concept.
Please share, if I may help you further in this regard.
A post was split to a new topic: How to Align a Table to the Center?