If you are looking for the easiest way of automating Excel to Word conversion in Java then you have landed at the right place. This article demonstrates how to convert Excel XLS or XLSX to Word DOC or DOCX in Java in a few easy steps.

XLSX to DOCX Java

Excel to Word conversion could be useful when you need to export data from a worksheet to a table in a Word document. To automate this conversion, this article covers how to convert Excel files to Word format in Java. Furthermore, additional options are also discussed to customize XLSX to DOCX conversion.

Excel to Word Java Converter - Free Download

Aspose.Cells for Java is a spreadsheet manipulation API that lets you generate, process, and manipulate Excel files. In addition, the API provides high-quality conversion of Excel XLSX files to other formats including DOCX, PDF, etc. You can either download the API or install it using the following Maven configuration.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-cells</artifactId>
    <version>21.3</version>
</dependency>

Steps to Convert Excel File to Word

Conversion of an Excel file to a Word document is as easy as pie. It can be done in a couple of easy steps using Aspose.Cells for Java:

  • Load the Excel file from storage.
  • Convert to Word format (i.e. DOC or DOCX) and save it to the desired location.

And that is it. Let’s now write the code in Java to convert an Excel file to a Word document.

Save an Excel XLSX to DOCX in Java

The following are the steps to convert an XLSX file to DOCX format.

The following code sample shows how to convert an Excel XLSX to Word DOCX in Java.

Java XLS to DOC Conversion - Customization

You can also customize Excel to Word conversion using different options provided by DocxSaveOptions class. The following is the list of options that you can use.

  • CachedFileFolder: The cache folder to store some large data.
  • ClearData: Make the workbook empty after saving the file.
  • CreateDirectory: If true and the directory does not exist, the
    directory will be automatically created before saving the file.
  • MergeAreas: Indicates whether to merge the areas of conditional
    formatting and validation before saving the file.
  • RefreshChartCache: Indicates whether refreshing chart cache data.
  • SortNames: Indicates whether to sort defined names before saving
    files.
  • UpdateSmartArt: Indicates whether to update the smart art setting.
  • ValidateMergedAreas: Indicates whether validate merged cells before saving the file.
  • WarningCallback: Gets or sets warning callback.

The following code sample shows how to use DocxSaveOptions class while exporting Excel files to Word DOC in Java.

Export Excel Files to Word in Java - Get a Free License

You can get a free temporary license to perform Excel to Word conversions from within your Java applications.

More to Read - Java Excel Converter API

You can explore more about Aspose.Cells for Java using documentation. Moreover, if you would have any questions or queries, feel free to contact us via our forum.

Conclusion

In this article, you have learned how to convert Excel XLS to Word DOC in Java. Furthermore, you have seen how to use different options to customize Excel to Word conversion.

See Also