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

I've 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


3 Replies

FS Fathima Shalini P Syncfusion Team December 7, 2007 02:22 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.






JM Josue Medrano December 10, 2007 08:54 AM UTC

Hi Fathima,
Thank you for your answer.
For me the problem is that if I set the alternating color in the template then I have to have the specific amount of rows as result. But I have not the specific rows as result, they are the resul from a query for instance.
Is there any way to get the parent table of CurrentMergeField? if so then I can use a Handler to do the alternating format.



FS Fathima Shalini P Syncfusion Team December 10, 2007 01:17 PM UTC

Hi Joshua,

To set the background color of the alternate rows, is not possible to do while mail merging the document. Please do find the simple sample in the following link.

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

The above sample retrieves the table from the document after the processing the mail merge and sets the background color for alternate rows.

Please let me know if this helps.

Regards,
Fathima.


Loader.
Live Chat Icon For mobile
Up arrow icon