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

Replace CRLF

Can you put a CRLF using the document.Replace Method?

I am trying to do a nested merge which looks like is not possible based on earlier posts...

for example

Have a list of projects with attributes and within the that list I want to perform another merge that pulls back a list based on the parent of project...


Project 1
Project Attrib 1
Project Attrib 2
Project Attrib 3

Project 1 corrections
correction 1
correction 2
correction 3

Project 2
Project Attrib 1
Project Attrib 2
Project Attrib 3

project 2 corrections
correction 1
correction 2
correction 3

Since I this is not possible or maybe it is (example please!) I can do the same by putting a CRLF into the replace command..

thx,

jon

7 Replies

SK Sarath Kumar G Syncfusion Team June 1, 2007 12:40 AM UTC

Hi Jon,

Thank you for your interest in Syncfusion products.

It is possible to perform Nested MailMerge. Here is the sample program for your reference.

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

Regarding CRLF, I am working on this issue. I will update you the status in a day.

Please, check with it and let me know if you face any issues.

Regards,
Sarath


JH Jon Howes June 1, 2007 03:55 PM UTC

I already looked at this nested example. This is not going to solve my problem... I need to being the data back into separate queries as the number of corections cold be any number (not hard coded to three in your example). I have considered using a cross tab query to make my returned dataset come back like yours but this would not be reasonable since I have no idea how many corrections have been added per project.


Document 1
Project 1
Correction 1
...
Correction n

Document 2
Project 2
Correction 1
...
Correction n

Essentially I get a list of projects and then run a query for each project to get a unknown list of corrections.

What I thought I could do would be to run the execute group off of the mailmerge event, but it does not have access to the document object once it hits that event.

I have abandoned the template approach and I am building the documents by hand in code.

If I could put a \r in the replace method I could still use the template....

jon


BP Bhuvaneswari P Syncfusion Team June 2, 2007 09:29 AM UTC

Hi Jon,

Thank you for your update.

This is not possible to create document for each project to get an unknown list of corrections using mail merge. However, this would be possible by using the below workaround, Generate each project separately and merge into one document using cloning and merging concept.

Please refer the below code snippet for your reference:

OleDbCommand cmd2 = new OleDbCommand("select * from MainTable", conn);
//Excute Query
IDataReader dataReader2 = cmd2.ExecuteReader();

while (dataReader2.Read())
{
// Create a new document
doc = new WordDocument();
// Load the template.
doc.Open((System.IO.Path.Combine(dataPath, @"project.doc")), FormatType.Doc);
//Select from Maintable
sql1 = "select * from MainTable where Project=" + "'" + dataReader2.GetValue(1).ToString() + "'";
cmd = new OleDbCommand(sql1, conn);
//Excute Query
IDataReader dataReader1 = cmd.ExecuteReader();

//Select from subtable
sql = "select Correction from SubTable where SubTable.Project=" + "'" + dataReader2.GetValue(1).ToString() + "'";
cmd1 = new OleDbCommand(sql, conn);
DataTable table = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter(cmd1);
da.Fill(table);
table.TableName = "SubTable";
// Execute Mail Merge with groups.
doc.MailMerge.ExecuteGroup(table);

// Execute Mail Merge
doc.MailMerge.Execute(dataReader1);

doc.Save("Sample.doc");
// Enumerate all the sections from the template document.
foreach (IWSection sec in doc.Sections)
{
// Cloning all the sections one by one and merging it to the new document.
doc1.Sections.Add(sec.Clone(doc1));
// Setting section break code to be the same as the template.
doc1.LastSection.BreakCode = sec.BreakCode;
}

You can download the sample from the below link:
http://websamples.syncfusion.com/samples/DocIO.Windows/F61754/main.htm

Herewith I have attached the generated document for your reference:
sample1.doc

Please let me know if you have any other queries.

Best Regards,
Bhuvaneswari


JH jon howes June 2, 2007 03:57 PM UTC

That is a great workaround.

I aprreciate you taking the time to generate the sample for me.


Best,

jon


BP Bhuvaneswari P Syncfusion Team June 4, 2007 12:32 PM UTC

Hi Jon,

Thank you for your interest in Essential DocIO.

Glad to know that it helps you.

Please let me know if you have any other queries.

Best Regards,
Bhuvaneswari


EM Ernie Molenaar June 10, 2007 11:13 PM UTC

Hi Jon,

If WordprocessingML (Word XML) is enough for you to generate your document, you should take a look at Emodox WordprocessingML.NET (http://www.emodox.com). I think it handles your "nested mailmerge" with ease. I believe there are also online demos to check out. I'm a developer for a dutch company and we use it since 3 weeks, and it's great. Only a pity it is not supporting Words binary format... Take a look and see for yourself. I hope this helped you.

Good luck.



>That is a great workaround.

I aprreciate you taking the time to generate the sample for me.


Best,

jon


MW Melba Winshia Syncfusion Team June 11, 2007 01:40 PM UTC

Hi Jon,

Kindly let us know if you have any other questions regarding Nested MailMerge.

Thanks,
Melba

Loader.
Live Chat Icon For mobile
Up arrow icon