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.
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 API
- Steps to Convert Excel File to Word
- Convert Excel XLS to Word in Java
- Customize XLSX to DOCX Conversion in Java
- Get a Free API License
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.
- First, load the Excel XLSX file using the Workbook class.
- Finally, convert XLSX to DOCX using Workbook.save(String, SaveFormat.DOCX) method.
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
- 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
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.