We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Create docx file from predefined template

We have to create docx file from docx predefined template. In template file we are put some placeholder and we want to replace placeholder with corresponding value and want to generate final docx.

is it possible in aspose? if yes how can i do it.

@bhausa2189,

Thanks for your inquiry. Yes, you can achieve your requirement using Aspose.Words. Please refer to the following article.
Find and Replace

If you still face problem, please ZIP and attach your input and expected output documents here for our reference. We will then provide you more information about your query.

Thanks for reply.

i seen all examples shown into documents after that i came into conclusion that ASPOSE is best for my use case. Still i have one question- suppose i have hierarchical object like
person {
name: ‘Test’,
Mob: ‘56556445’,
Address:{
City : ‘Pune’,
Country: ‘INDIA’
}
}

i have placeholder likes : <Person.name>, <Person.Mob>,<Person.Address.City>,<Person.Address.country>

so instead of iterating over the object i want to replace or map corresponding objects field contents to placeholder. Can you please give me some input for same .

@bhausa2189,

Thanks for your inquiry. In your case, we suggest you please use our LINQ Reporting engine to achieve your requirement. Please read template syntax of LINQ Reporting and some typical templates. Hope this helps you.

Great…Thanks for suggestion.

I have one more question How to compare string in LINQ conditional tags? i am trying by using below codes but unfortunately its not working.

<<if [Contacts.Type==‘Mobile’]>>
Mobile : <<[Contacts.MobileNo]>>
<>
LandLine : <<[Contacts.LandLineNo]>>
<>

Please suggest if doing anything wrong.

Thanks found solution. Is it possible to define custom tags in template by using LINQ?

@bhausa2189,

Thanks for your inquiry. You cannot define custom tags in template for LINQ Reporting. Please let us know if you have any more queries.

Hi Tahir,

One more question- I have XML documents that contains all necessary data required for document generation. Is it possible to load XML documents and generate Dataset/Datatable objects as required? As per documentation i seen its possible by using old mail-merged-region API. But I didn’t seen any documentation of same by using LINQ API. Please provide me input on same.image.png (15.2 KB)

Hi,
Along with above details also tell me How to put placeholders in header n footer and replace corresponding values by using customeBean objects using LINQ?

Thanks,
Bhausaheb

@bhausa2189,

Thanks for your inquiry.

Yes, you can use DataSet/DataTable as data source. Please refer to the following article.
Working with Traditional Mail Merge Data Sources

You can use the same approach for placeholders in header and footer as you are doing. We suggest you please check the code examples of LINQ Reporting from Aspose.Words for .NET examples repository at GitHub.