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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DocIO - working with tables

Thread ID:

Created:

Updated:

Platform:

Replies:

144662 May 16,2019 09:38 AM UTC May 17,2019 08:40 AM UTC WPF 2
loading
Tags: DocIO
Béatrice Daems
Asked On May 16, 2019 09:38 AM UTC

Hello,

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.AddParagraph().AppendText("Année");
                cell = row.AddCell();
                cell.AddParagraph().AppendText("Régime");
                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

Mohanaselvam  Jothi [Syncfusion]
Replied On 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:
https://help.syncfusion.com/file-formats/docio/working-with-paragraph#working-with-text
https://help.syncfusion.com/file-formats/docio/working-with-tables

Please let us know if you have any other questions.

Regards,
Mohanaselvam J
 


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

Thank you very much for your answer.

Kind regards, 

Beatrice

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon