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

Dealing with word template

I have two requirements

1. After uploading a word template to server I want only to retrieve data from table which match to fields in word template. As an example suppose my template consists with <<name>> and <<tel no>> fields. Without having knowledge about it but just using template get the details of those columns. (In simple word read the fields in word template )

 

2. This is little bit  related to 1st one, What will happen when if user uploads wrong template, How do I check that (I mean content)..

Thanks


7 Replies

CH Chathuranga November 19, 2012 10:57 AM UTC

I found this method 

string[] fieldNames = doc.MailMerge.GetMergeFieldNames();

but this works only for EmployeesReportDemo.doc template given by Syncfusion and it also only gives the first field name only.( <<Employees>> ). And this is not working templates which generated by my self. I follow correct way to create templates. Please help me. 



RM Ramkumar M Syncfusion Team November 19, 2012 10:58 AM UTC

Hi Chathuranga,

Thank you for your interest in Syncfusion products.

We are not able to reproduce the mentioned issue with GetMergeFieldNames() method. For your reference please find the sample that we have used to reproduce the issue.

Sample:

http://www.syncfusion.com/downloads/Support/DirectTrac/99902/Sample411530762.zip

Could you please provide us the input document and code snippets that you have used on your side? So that we can analyze further the exact cause of issue and provide you the proper solution.

Please let us know if you have any question.

Regards

Ramkumar



CH Chathuranga November 19, 2012 10:59 AM UTC

Hello 

thanks for your reply, 

 

I looked at the project you provided here, It works well, But the case is I am using web forms, I have tested this thing in vs2008 with WCSF (which I really need to apply this thing) and in vs2010(.4). Non of then get correct results. So I attached both projects with this. Please have a look at about it and I am appreciating your help 



WebClientApplication1_1d8ddaf5_3adb2e0f.rar


CH Chathuranga November 19, 2012 11:00 AM UTC

please I need help



RM Ramkumar M Syncfusion Team November 19, 2012 11:00 AM UTC

Hi Chathuranga,

Thank you for your update.

On analyzing your sample application, we found that you have used document.MailMerge.GetMergeGroupNames() to get merge field names available in the document. But document.MailMerge.GetMergeGroupNames() return only collection of the Merge Field Group names (table names) available in the document  like <TableStart:Tablename>” and “<BeginGroup:TableName>”.

You can get the collection of the Merge Fields available in the document by using the doc.MailMerge.GetMergeFieldNames() method. To get collection of the Merge Fields for a specific group in the document by using the doc.MailMerge.GetMergeFieldNames(String groupName) method. 

For more information on DocIO mail merge functions please refer the below link

http://help.syncfusion.com/UG/Reporting/DocIO/ASP.NET/default.htm#!documents/463additionalmailmergefeatures.htm

For your reference please use the below code snippets and let us know if this helps you.

Code snippets:

string templateFilePath = Server.MapPath("~/db/t1.doc");

WordDocument document = new WordDocument();// Creating a new document.

document.Open(templateFilePath, FormatType.Doc); // Load template

string[] groupNames = document.MailMerge.GetMergeGroupNames();

//To get merge fields of particular group(particular table)          

foreach (string group in groupNames)

    {

       string[] mergeFieldsInParticularGroup = document.MailMerge.GetMergeFieldNames(group);

 

     }

//To get all merge available in the document

string[] allMergeFields = document.MailMerge.GetMergeFieldNames();

 

Please let us know if you have any question.

Regards

Ramkumar



CH Chathuranga November 19, 2012 11:01 AM UTC

thanks



DY Deivaselvan Y Syncfusion Team November 20, 2012 04:39 AM UTC

Hi Chathuranga,

Thank you for your update.

Please let us know if you have any other questions.

Regards,
Deiva selvan


Loader.
Live Chat Icon For mobile
Up arrow icon