Modify the style of a row in a table under condition

Hi

I am currently working on generating PDF documents from a Word document. In the Word document there is a table that I am filling using the merge fields. The filling works perfectly but I would like to apply a style to some rows of the table. To make it simple I would like to change the background color of the cells in case the cell on the header "stock star" contains a value. I have found examples to change the style of the whole table but no specific row. Can you give me some advice on how to do it.

I am attaching the word document I am working with and an example of the result I would like to obtain.

Thanks

Quentin


Attachment: example_b069eb2.zip

2 Replies

SB Suriya Balamurugan Syncfusion Team June 9, 2022 10:05 AM UTC

Hi Quentin,

From the given details, we have found that your requirement is to formatting the table rows (change the background color) when the specific field contains a value.

To achieve your requirement, we suggest you to use
MergeFieldEvent and formatting the owner row of specific merge field if there is a field value. We have prepared a sample application to change the background color of the table row when specific merge field contains a value as per your requirement and it can be downloaded from the below attachment.

In the above sample, we have done the following things:
  1. Opens a template Word document.
  2. Creates data for mail merge execution.
  3. Using
MergeField event, change the background color of the rows of specific field which contains a value.
  4. Saves the Word document to PDF after executing mail merge.

Please refer the below link to know more about mail merge events:
https://help.syncfusion.com/file-formats/docio/mail-merge/mail-merge-events
https://github.com/SyncfusionExamples/Mail-Merge-Examples

Regards,
Suriya Balamurugan.



Attachment: FormatRowsForSpecificField_f9bb99b7.zip


CQ Chaffois Quentin replied to Suriya Balamurugan June 9, 2022 12:14 PM UTC

Hello;

First of all, thank you for the quick response. I have just retrieved the draft example in your reply and it suits my request perfectly. So I have integrated these elements in my project and the PDF is generated as it should be.

Thank you


Loader.
Up arrow icon