This is a migrated thread and some comments may be shown as answers.

RadRichTextBox with MailMerge functionality

1 Answer 81 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Muhammad Ummar
Top achievements
Rank 1
Muhammad Ummar asked on 23 May 2016, 11:39 AM

Hello,

I am using RadRichTextBox in my project as a reporting tool. I have created a basic structure of application and it seems to be working fine. I am setting MailMergeDataSource to a collection to generate report of more than one selected records. For example If a user selects 10 records, 10 pages will be created in final report. (assuming 1 page per report). User can now edit the generated report (like formatting, refining and so on). Till this point it seems to be achievable. I further want to get all these 10 updated pages of reports separately (with the changes done on the view), I am not sure how to do it.

Following is the line I am using for MailMerge

 

radRichTextBox.Document = radRichTextBox.MailMerge(); //Start each record on new page.

 

I am not sure how to get the boundaries of each report. because if I use the API to regenerate each report the changes done on the print preview will be lost.

This is what I am talking about

IDocumentFormatProvider formatProvider = DocumentFormatProvidersManager.GetProviderByExtension(".docx");

for (int i=0;i<number_of_records; i++)

this.radRichTextBox.Document.MailMergeDataSource.MoveToFirst();

var doc = this.radRichTextBox.MailMergeCurrentRecord(); // returns a RadDocument that is the result of substituting the merge fields with the data from the current record.

byte[] binnaryReportData = formatProvider.Export(doc); //but changes will be lost

this.radRichTextBox.Document.MailMergeDataSource.MoveToNext();

}

 

How can I achieve this?

1 Answer, 1 is accepted

Sort by
0
Muhammad Ummar
Top achievements
Rank 1
answered on 25 May 2016, 09:44 AM

Formatted code 

 

01.IDocumentFormatProvider formatProvider = DocumentFormatProvidersManager.GetProviderByExtension(".docx");
02. 
03.for (int i=0;i<number_of_records; i++)
04.{
05.    this.radRichTextBox.Document.MailMergeDataSource.MoveToFirst();
06.    var doc = this.radRichTextBox.MailMergeCurrentRecord(); // returns a RadDocument that is the result of substituting the merge fields with the data from the current record.
07.    byte[] binnaryReportData = formatProvider.Export(doc); //but changes will be lost
08.    this.radRichTextBox.Document.MailMergeDataSource.MoveToNext();
09.}

Tags
RichTextBox
Asked by
Muhammad Ummar
Top achievements
Rank 1
Answers by
Muhammad Ummar
Top achievements
Rank 1
Share this question
or