We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DocIO - working with tables


I am working on a WPF project and using syncfusion DocIO I am creating a table in a word Document. I am a beginner and I don't manage to change the fontsize of all the cells of my table. Is textRange.CharacterFormat.FontSize available for the paragraphs I added on my cells ? I have tried without succees. Below, an extract of my code : private WTable InsererTableau(WordDocument document)
            WTable tableauRdc = new WTable(document);
            tableauRdc.Description = "Relevé de carrière passées et futures";
            tableauRdc.TableFormat.IsAutoResized = true;
            tableauRdc.TableFormat.HorizontalAlignment = RowAlignment.Center;
            tableauRdc.TableFormat.Paddings.All = 5;
            tableauRdc.TableFormat.Borders.LineWidth = 1f;
            tableauRdc.TableFormat.Borders.Color = Color.Orange;
            tableauRdc.ApplyStyleForHeaderRow = true;
            if (Item.AnneeCarriere != null)
                WTableRow row = tableauRdc.AddRow();
                row.IsHeader = true;
                row.RowFormat.BackColor = Color.WhiteSmoke;
                WTableCell cell = row.AddCell();
                cell = row.AddCell();
                cell = row.AddCell();
                cell.AddParagraph().AppendText("Revenu annuel");
                cell = row.AddCell();
                cell.AddParagraph().AppendText("Nb de trimestres");
                cell = row.AddCell();
                cell.AddParagraph().AppendText("Nb de points Arrco");
                cell = row.AddCell();
                cell.AddParagraph().AppendText("Nb de points Agirc");
                cell = row.AddCell();
                cell.AddParagraph().AppendText("Nb de points autres");
                foreach (WTableCell cel in row.Cells)
                    cel.CellFormat.VerticalAlignment = VerticalAlignment.Middle;
                    cel.CellFormat.Paddings.All = 0;
                    foreach (WParagraph paragraph in cel.Paragraphs)
                        paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
                } Could anyone be so kind to help me ? Thanks in advance for your answers. Kind regards Beatrice

2 Replies

MJ Mohanaselvam Jothi Syncfusion Team May 17, 2019 04:22 AM UTC

Hi Beatrice,

To achieve your requirement, we suggest you iterate into paragraph elements and set font size for text (WTextRange). Please refer the below code snippet to achieve this at your end:
foreach (WParagraph paragraph in cel.Paragraphs) 
    paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center; 
    foreach(ParagraphItem paragraphItem in paragraph) 
        if(paragraphItem is WTextRange) 
           WTextRange textRange = paragraphItem as WTextRange; 
           textRange.CharacterFormat.FontSize = 10f; 

Please refer our documentation link to know more about working with text in the Word document using DocIO:

Please let us know if you have any other questions.

Mohanaselvam J

BD Béatrice Daems May 17, 2019 08:40 AM UTC

Thank you very much for your answer.

Kind regards, 


Live Chat Icon For mobile
Up arrow icon