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

Using the same Fonts

table[value_y - 2, value_x - 1].AddParagraph().AppendText("bla");
table[value_y - 2, value_x ].AddParagraph().AppendText("bla");

table[value_y - 1, value_x - 1].AddParagraph().AppendText("bla");
table[value_y - 1, value_x ].AddParagraph().AppendText("bla");

table[value_y, value_x - 1].AddParagraph().AppendText("bla");
table[value_y, value_x ].AddParagraph().AppendText("bla");

For this snippet

7 Replies

SY Sethumanikkam Yogendran Syncfusion Team October 17, 2016 06:03 AM UTC

Hi Customer,

Thank you for contacting Syncfusion support.

Please find the below code snippets for your requirement, in this code snippet we were tried to create custom style with font formatting and applied it to the paragraph of table.

//Adds a new paragraph style named "MyStyle" 
IWParagraphStyle myStyle = wordDocument.AddParagraphStyle("MyStyle"); 
//Sets the formattings of the style 
myStyle.CharacterFormat.FontName = "Arial"; 
myStyle.CharacterFormat.FontSize = 17f; 
 
IWParagraph iWParagraph = wTable[value_y - 2, value_x - 1].AddParagraph(); 
//Applies the style to paragraph 
iWParagraph.ApplyStyle("MyStyle"); 
//Appends the contents into the paragraph 
iWParagraph.AppendText("bla");

Note: Apply this custom style to all paragraphs to get same fonts in the resultant document.

Please refer the following link to know more about how to work with tables and apply formatting using styles.
https://help.syncfusion.com/file-formats/docio/working-with-paragraph#applying-paragraph-formatting
https://help.syncfusion.com/file-formats/docio/working-with-word-document#working-with-styles

If we misunderstood your requirement, kindly update us requirement with clear description. Thereby we will analyze further on the mentioned requirement and update you with appropriate solution.

Please let us know if you have any further questions.

Thanks,
Sethumanikkam.Y



MV mvxyc October 18, 2016 05:58 AM UTC

Thanks, but how to change the entire content of a cell plus format it with custom styling instead of adding a paragraph ?


SY Sethumanikkam Yogendran Syncfusion Team October 19, 2016 05:49 AM UTC

Hi Customer,

Thank you for your update.

On further analysing with the given details we suspect anyone of the following is your requirement.

1. Load input Word document which contains table.
2. Create a new custom paragraph style with its formatting (for example: Font formatting).
3. Apply created paragraph style to all paragraphs which exist in particular table cell.

Kindly provide your confirmation on the mentioned cases, thereby we will analyse further and will provided you appropriate solution.

For more details kindly refer following UG Link:
https://help.syncfusion.com/file-formats/docio/working-with-tables
https://help.syncfusion.com/file-formats/docio/working-with-paragraph#applying-paragraph-formatting

If we misunderstand your requirement then, kindly provide us Input document used (if any) and screenshot/output Word document of the expected result which will helpful to provide you the appropriate solution


Thanks,
Sethumanikkam.Y



TE Testname October 19, 2016 09:25 AM UTC

Based on this example:
//Adds a new paragraph style named "MyStyle" 
IWParagraphStyle myStyle = wordDocument.AddParagraphStyle("MyStyle"); 
//Sets the formattings of the style 
myStyle.CharacterFormat.FontName = "Arial"; 
myStyle.CharacterFormat.FontSize = 17f; 
 
IWParagraph iWParagraph = wTable[value_y - 2, value_x - 1].AddParagraph(); 
//Applies the style to paragraph 
iWParagraph.ApplyStyle("MyStyle"); 
//Appends the contents into the paragraph 
iWParagraph.AppendText("bla");


Instead of adding a paragraph I want to overwrite the entire content of the cell.

How to do this ?




SY Sethumanikkam Yogendran Syncfusion Team October 19, 2016 01:08 PM UTC

Hi Customer,

Thank you for your update.

We have prepared a sample to meet your requirement. In this sample, we have created “ApplyFormattingForCellContent” extension method and passing ‘WTableCell’ as argument to apply formatting for all its contents.

Please find the below sample which illustrates the same, and let us know if it helps you.
http://www.syncfusion.com/downloads/support/forum/126416/ze/Forum-126416-245560135.zip

If we misunderstood your requirement, kindly update us requirement with clear description. Thereby we will analyze further on the mentioned requirement and update you with appropriate solution.

Please let us know if you have any other questions.

Thanks,
Sethumanikkam.Y



TE Testname October 24, 2016 12:38 PM UTC

Yes, it is much better, but I don't want to append a text I want to overwrite the cell. How ?


SY Sethumanikkam Yogendran Syncfusion Team October 25, 2016 06:08 AM UTC

Hi Customer,

Thank you for your update.

We have prepared a sample to meet your requirement. In this sample, we have done the following things as per your requirement.

1.  Loaded existing Word document which contains table using DocIO
2.  Accessed instance of Table from Section.
3.  Iterated Cell contents through Table elements.
4.  Overwritten Font formatting to all contents in Cell.
Note: Input Word document (bla.docx) exists in App_Data folder inside the DocIOApplication.

Please find the below which illustrates the same, and let us know if it helps you.
http://www.syncfusion.com/downloads/support/forum/126416/ze/Forum-126416-1345550519.zip

Please refer the following links to know more about how to work with tables, iterations of word document elements, and how to work with text.
https://help.syncfusion.com/file-formats/docio/working-with-tables
https://help.syncfusion.com/file-formats/docio/working-with-word-document#iterating-through-document-elements
https://help.syncfusion.com/file-formats/docio/working-with-paragraph#working-with-text

If we misunderstood your requirement, kindly update us requirement with clear description. Thereby we will analyze further on the mentioned requirement and update you with appropriate solution.

Please let us know if you have any other questions.

Thanks,
Sethumanikkam.Y
 


Loader.
Up arrow icon