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

Mail Merge and export as HTML with merged tags

9 Answers 582 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Justin
Top achievements
Rank 1
Justin asked on 05 Oct 2011, 11:41 PM

Hi,

Is there a way of saving an Html document to which Mail Merge tags were added in order to run the mail merge at another time or using another tool?

For example, when creating/editing a Word document using RadRichText, I can add Mail Merge tags (fields) to the document and save that document without clicking the Mail Merge (Finish) button. This way may (mail merge) tags are saved so that when re-opening the document, I can continue adding mail merge items or complete the mail merge at that point (or even link it to a different dataset).

When I create/open and HTML document and try to export as Html (or even save as an Html document) after adding tags, I receive the following error:

This inline is not supported: FieldRangeStart

My end goal is to be able to export the html document (with tags) in order to store it in the database and import again later to modify and finally merge the data.

Thank you

9 Answers, 1 is accepted

Sort by
0
Joe
Top achievements
Rank 1
answered on 11 Oct 2011, 05:11 AM
I would like to do the same thing except with OpenXML.   I would love the ability to have a .docx that could saved my MERGE FIELD place holders so that I can merge the document with other data sources.   Is this possible?
0
Boby
Telerik team
answered on 11 Oct 2011, 01:37 PM
Hello Joe, Attention: Norm,
@Joe There is a known bug with importing merge fields from docx in 2011 Q2, if you are using it you should upgrade to Q2 SP1 in order to use this functionality.

@Attention: Norm: As merge fields are not supported by HTML, our HtmlFormatProvider don't export them. You can instead use XamlFormatProvider or DocxFormatProvider (and XAML or docx as intermediate format), which support importing/exporting merge fields.

Kind regards,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Joe
Top achievements
Rank 1
answered on 12 Oct 2011, 04:02 AM
Thanks for the reply.   I got the latest assemblies, but I am still having a problem.    I am trying to get a document that has the merge field place holders in the DOCX file.   However, when I export the file the contents are saved with the merged data and not with the merge field placeholders.

Because of this I cannot have a "template" document that can be later imported so as to merge with other data.

I tried to manually put a DOCX file together with the merge field place-holders using Microsoft Word, but those fields are just imported as plain text and will not map to the data.

Any suggestions?
0
Justin
Top achievements
Rank 1
answered on 13 Oct 2011, 02:55 PM
Hi Boby,

I modified my logic to try and replace the mail merge tags with different tags using search and replace.

This seems to change the Telerik Mail Merge tags (ie. { MERGEFIELD FieldName } ) but it appears that when Mail Merge fields are added to the document that there are some hidden tags which still prevent saving using the HtmlFormatProvider.

When instead I highlight the mail merge tag and delete it and then try to save using the HtmlFormatProvider, it works fine.

How can I add in the merge fields so that I am able to preview the document by selecting Preview Results, then in order to save showing all field codes again (which I have coded already), and then replace the Telerik Mail Merge field tags with my own so that the HtmlFormatProvider doesn't have issues?

Thanks


NOTE: I have opened a support ticket for this...
0
Accepted
Boby
Telerik team
answered on 17 Oct 2011, 09:58 AM
Hello Joe, Attention: Norm,
@Joe: Actually the merge fields are exported to docx format, but they preserve a value from the previous data source. If you update them in any way, you will see the values from the new data source, for example:
// set your data source here
this.radRichTextBox.Document.MailMergeDataSource.ItemsSource = new List<Person>()
{
    new Person()
    {
        FirstName = "Aaaa",
        JobTitle =  "Bbb"
    }
};
 
// change fields display mode
this.radRichTextBox.ChangeAllFieldsDisplayMode(FieldDisplayMode.Result);
If you are sure that the merge fields are imported as plain text, there should be some problem with the import of the document, so we will appreciate if you send us a sample docx document reproducing the problem.

@Attention: Norm:
We answered you in the support ticket you opened.

All the best,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Joseph
Top achievements
Rank 1
answered on 20 Oct 2011, 02:48 PM
Hi Any solution to the problem with the templates. I am have the same issues as joe. I cannot create a mail merge template as the merg fields are lost when exported to a docx :(
0
Boby
Telerik team
answered on 25 Oct 2011, 08:45 AM
Hi Joseph,
Mail merge fields are preserved in docx export-import round-trip, but they preserve a value from the data source in their presentation (please refer to the solution in my previous post for this).
If you continue to experience problems, please send us a sample document (exported to XAML), which fails to export its merge fields to docx.

Greetings,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
steven littleford
Top achievements
Rank 1
answered on 21 Feb 2012, 12:33 AM
I have a slightly similar issue.

I'm exporting my merge fields as Xaml, and its importing exporting correctly.

However, i'm also using Custom Fields which i use to bring in dynamic sets of data. And it seems to export correctly, however when i import i get the following crash:


Crash when loading Custom Merge Field into RadDocument from XAML

The tag 'CustomMergeField' does not exist in XML namespace 'clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents'. Line '18' Position '10'.

   at System.Windows.Markup.XamlParser.ThrowExceptionWithLine(String message, Int32 lineNumber, Int32 linePosition)

   at System.Windows.Markup.XamlParser.ThrowException(String id, String value1, String value2, Int32 lineNumber, Int32 linePosition)

   at System.Windows.Markup.XamlParser.WriteUnknownTagStart(XamlUnknownTagStartNode xamlUnknownTagStartNode)

   at System.Windows.Markup.XamlParser.ProcessXamlNode(XamlNode xamlNode, Boolean& cleanup, Boolean& done)

   at System.Windows.Markup.XamlParser.ReadXaml(Boolean singleRecordMode)

   at System.Windows.Markup.TreeBuilderXamlTranslator._Parse()

   at System.Windows.Markup.XamlParser.Parse()

   at System.Windows.Markup.XamlTreeBuilder.ParseFragment()

   at System.Windows.Markup.TreeBuilder.Parse()

   at System.Windows.Markup.XamlReader.XmlTreeBuildDefault(ParserContext pc, XmlReader reader, Boolean wrapWithMarkupCompatReader, XamlParseMode parseMode, Boolean etwTracingEnabled)

   at System.Windows.Markup.XamlReader.Load(XmlReader reader)

   at System.Windows.Markup.XamlReader.Parse(String xamlText)

   at Telerik.Windows.Documents.FormatProviders.Xaml.XamlFormatProvider.Import(String input) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Documents\Telerik.Windows.Documents.FormatProviders.Xaml\XamlFormatProvider.cs:line 126



I gather that this is just not supported, but is there any other way to do this? I've got the custom fields working great, i'd just like to be able to import documents with these in there.

The only thing i can think of is having my own process to add it back in manually, but that is really messy.

Cheers,
Steve
0
Ivailo Karamanolev
Telerik team
answered on 24 Feb 2012, 10:39 AM
Hello,

Since 2011 Q3 SP1, we support importing and exporting custom document elements, so your scenario will be supported without extra effort. However, if upgrading is not an option for you, I can suggest a workaround: before export, you replace all your custom fields with bookmarks, serializing your field info in the bookmark name, and recreating the fields upon import.
Let us know if you need additional assistance.

Greetings,
Ivailo Karamanolev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
RichTextBox
Asked by
Justin
Top achievements
Rank 1
Answers by
Joe
Top achievements
Rank 1
Boby
Telerik team
Justin
Top achievements
Rank 1
Joseph
Top achievements
Rank 1
steven littleford
Top achievements
Rank 1
Ivailo Karamanolev
Telerik team
Share this question
or