Can we create Word document using template

Hi,
I want to create word document using template. I don’t know it is possible or not. See, i want to create HTML template and from that HTML template i want to create word document and if it is possible can i use xsd file as well. Or it is possible using any other template. In the data i am having some dynamic data where i also need list of data and as well as if condition. I mean for some data i will be having rows that will come as a list of data. Also i want to create header, footer, TOC(Table of contents) everything from template. Can you tell me what all things are possible or nothing is possible using any type of template?

Thanks
Raviranjan

Hi, I am waiting for the response. Can anybody help me regarding this?

Thanks

Raviranjan

Hi Raviranjan,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word do.

Yes, You can convert your html template to MS Word document by using Aspose.Words. Could you please share what exact you want to achieve by using xsd file? Please share some more detail about your query along with input and expected output document.

Document doc = new Document(MyDir + "in.html");
doc.Save(MyDir + "Out.docx", SaveFormat.Docx);

You can create header/footer and table of contents by using Aspose.Words, please read following documentation link.
https://docs.aspose.com/words/java/working-with-headers-and-footers/
https://docs.aspose.com/words/java/working-with-table-of-contents/

Aspose.Words can generate documents from templates with mail merge fields. The data from an external source like a database or file is placed into these fields and formatted, and the resulting document is saved in the folder you specify. I suggest you please use the Mail Merge feature as explained in following documentation links:
https://docs.aspose.com/words/java/mail-merge-and-reporting/
https://docs.aspose.com/words/java/types-of-mail-merge-operations/

Hi, Thanks for your reply. I am attaching the sample document file which should be create from the template. Here all data is dynamic. So basically i want to have some template so i will pass data and it should create dynamic doc file. Here i want to create even TOC from template. File also contains Table which contains dynamic data with dynamic rows. Also if you see Header 3, this contains different type of input so it should also come from html (like Input Box, Dropdown, Checkbox, Radiobutton,…). Also Background color of table header(that will be fixed but it will come from HTML file). Also i want to create Header and footer from template. As i mentioned about xsd file, because i can put if condition, loop for generating dynamic HTML file (if Aspose does not support xsd file). So can you let me know is it possible or not to generate from HTML(or any other template), if it is possible then what all limitation(s) are there?

Hi Raviranjan,

Thanks for sharing the document.

raviranjankumarsinha:
I am attaching the sample document file which should be create from the template. Here all data is dynamic. So basically i want to have some template so i will pass data and it should create dynamic doc file.

In your case, I suggest you please use the Mail Merge feature. Please read following documentation links for your kind reference.
https://docs.aspose.com/words/net/working-with-document/
https://docs.aspose.com/words/net/mail-merge-and-reporting/

raviranjankumarsinha:
Here i want to create even TOC from template. File also contains Table which contains dynamic data with dynamic rows.

You can insert TOC and create Table with dynamic data by using Aspose.Words. Please check following documentation and forum links.
https://docs.aspose.com/words/net/working-with-tables/
https://forum.aspose.com/t/51128

raviranjankumarsinha:
Also if you see Header 3, this contains different type of input so it should also come from html (like Input Box, Dropdown, Checkbox, Radiobutton,…).

Placing form fields into the document via code is easy. DocumentBuilder has special methods for inserting them, one for each form field type. Use DocumentBuilder.InsertTextInput, DocumentBuilder.InsertCheckBox or DocumentBuilder.InsertComboBox to insert form fields into a document. Please read more detail about Form Fields from here:
https://docs.aspose.com/words/net/working-with-form-fields/
https://reference.aspose.com/words/net/aspose.words.fields/formfield/

raviranjankumarsinha:
As i mentioned about xsd file, because i can put if condition, loop for generating dynamic HTML file (if Aspose does not support xsd file). So can you let me know is it possible or not to generate from HTML(or any other template), if it is possible then what all limitation(s) are there?

Aspose.Words does not support xsd file format. You can generate the same document (sample.docx) by using Aspose.Words except form fields (the radio button), please check the detail from above Form Field documentation link.

Hope this answers your query. Please let us know if you face any issue while creating document with any section like header/footer, TOC, form fields, table etc.