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
close icon

Alternating Rows in in table / Find text in a cell and change the cell format

Alternating Rows in in table / Find text in a cell and change the cell format

I've got an evaluation version of DocIO, I am trying to accomplish some requirements, so far most of then are fulfilled, however I'd like to expose the following questions:

1. Using MailMerge is it possible to change the format of the table alternating its Background color?

2. I have a PlainText in a cell (Table) which I would to find and then change the Background of the CELL where it is placed, is is possible to do it.

If yes, could please provide me an example of it.
I appreciate your help.

Best regards,
Josue Medrano

UBS AG
Global Wealth Management & Business Banking
Information Technology
HR & EDUCATION SOLUTIONS
Tel. +41-61-288 27 62
Fax +41-61-288 20 57
www.ubs.com

Josue.medrano-cruz@ubs.com


2 Replies

FS Fathima Shalini P Syncfusion Team December 7, 2007 02:21 PM UTC

Hi Joshua,

Thanks for your interest in Syncfusion Products.

1) In mail merge to set the alternate backcolor in tables we need to set the backcolor in template document. DocIO does not support this at run time. Please do find

the simple sample that illustrates setting alternate background color using mail merge.

http://websamples.syncfusion.com/samples/DocIO.Windows/F70313_1/main.htm

2) Please do find the simple sample in the following link that traces a text and finds the cell and changes its background color.

http://websamples.syncfusion.com/samples/DocIO.Windows/F70313_2/main.htm

The following code snippet illustrates this.

[C#]


public bool Find(string str)
{
int k = 1;
foreach(IWSection sec in document.Sections)
{
foreach (IWTable table in sec.Tables)
{

int r = table.Rows.Count;

for (int i = 0; i < r; i++)
{
int c = table.Rows[i].Cells.Count;
WTableRow r1 = table.Rows[i];
for (int j = 0; j < c; j++)
{
if (str.Equals(r1.Cells[j].Paragraphs[0].Text))
{
MessageBox.Show(str + " is found in " + (i + 1) + "Row " + (j + 1) + "Cell in Table" + k, "FindOnce");
r1.Cells[j].CellFormat.BackColor = Color.Blue;
return true;
}
}
}
k++;
}
}
return false;

}


Please try this and let me know if this helps.

Regards,
Fathima.






FJ Florene J Anderson replied to Fathima Shalini P November 22, 2020 02:43 PM UTC

Hi Joshua,

Thanks for your interest in Syncfusion Products.


1) In mail merge to set the alternate backcolor in tables we need to set the backcolor in template document. DocIO does not support this at run time. Please do find

the simple sample that illustrates setting alternate background color using mail merge.

http://websamples.syncfusion.com/samples/DocIO.Windows/F70313_1/main.htm

guys, if you need help writing or reviewing an article, I would advise you to pay attention to the service https://edubirdie.com/article-review-writing, which will be able to write a high-quality review of a particular article in the shortest lines.

2) Please do find the simple sample in the following link that traces a text and finds the cell and changes its background color.

http://websamples.syncfusion.com/samples/DocIO.Windows/F70313_2/main.htm

The following code snippet illustrates this.

[C#]

 public bool Find(string str)
{
int k = 1;
foreach(IWSection sec in document.Sections)
{
foreach (IWTable table in sec.Tables)
{

int r = table.Rows.Count;

for (int i = 0; i < r; i++)
{
int c = table.Rows[i].Cells.Count;
WTableRow r1 = table.Rows[i];
for (int j = 0; j < c; j++)
{
if (str.Equals(r1.Cells[j].Paragraphs[0].Text))
{
MessageBox.Show(str + " is found in " + (i + 1) + "Row " + (j + 1) + "Cell in Table" + k, "FindOnce");
r1.Cells[j].CellFormat.BackColor = Color.Blue;
return true;
}
}
}
k++;
}
}
return false;

}

Thank you so much for sharing. It's very helpful to me.

Loader.
Live Chat Icon For mobile
Up arrow icon