Articles in this section
Category / Section

How to create Word document in Java

1 min read

Syncfusion® Java Word library (Essential® DocIO) is used to create, read, and edit Word documents programmatically without Microsoft Word or Interop dependencies. Using this library, you can create Word document in the Java application.

Steps to create Word document programmatically in Java

  1. Create a new HelloWorld.java file and include the following namespaces.

JAVA

import com.syncfusion.docio.*;
  1. Use the following code sample to create a Word document with a simple text.

JAVA

// Creates a new instance of WordDocument (Empty Word Document).
WordDocument document = new WordDocument();
// Add a section and a paragraph to the document.
document.ensureMinimal();
// Append text to the last paragraph of the document.
document.getLastParagraph().appendText("Hello World");
// Save the Word document.
document.save("Result.docx");
// Close the Word document.
document.close();

A complete working example of how to create a Word document in Java can be downloaded from GitHub.

By executing the program, you will get the Word document as follows,

Generated or created Word document

You can refer to here to know about how to run the Syncfusion® Java Word library (Essential® DocIO).

Take a moment to peruse the documentation. You can find the basic Word document processing options along with features like mail merge, merge, and split documents.

Explore more about a rich set of Syncfusion® Word Framework features.

A Github example to generate or create a Word document with basic elements.



Conclusion
I hope you enjoyed learning how to create Word document in Java.
You can refer to our Java Word library feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Java Word example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied