Hi aspose team.
Hi
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your inquiry. To center the table you should loop over all rows in this table and specify alignment of each row. For instance, see the following cod:
// Open document.
Document doc = new Document(@"Test001\in.doc");
// Get table that should be centered. for example the first one.
Table table = doc.FirstSection.Body.Tables[0];
// Loop over all rows in table and set alignment.
foreach (Row row in table.Rows)
row.RowFormat.Alignment = RowAlignment.Center;
// Save result.
doc.Save(@"Test001\out.doc");
Hope this helps. Please let me know if you need more assistance, I will be glad to help you.
Best regards,
Thanks a lot alexy,For your useful and soon reply. It worked correctly.
Hi
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your inquiry. If you need to center content in the table, you need to specify alignment of paragraphs inside the table. For instance, see the following code:
// Open document.
Document doc = new Document(@"Test001\in.doc");
// Get table. for example the first one.
Table table = doc.FirstSection.Body.Tables[0];
// Loop over all paragraphs in the table and cetrer them.
Node[] paragraphs = table.GetChildNodes(NodeType.Paragraph, true).ToArray();
foreach (Paragraph par in paragraphs)
par.ParagraphFormat.Alignment = ParagraphAlignment.Center;
// Save result.
doc.Save(@"Test001\out.doc");
Hope this helps.
Best regards,
Thanks a lot again. I got it.