This guide shares details for conversion from Word to Excel in Java. It has all the details to set the IDE, a list of steps, and a sample code to change the file format from Word to Excel in Java. You will learn to set the input file format and output file format as per your requirements using the LoadOptions and SaveFormat.
Steps to Convert DOCX to XLSX in Java
- Set the environment to use Aspose.Words for Java to transform DOCX to XLSX
- Create the LoadOptions class object for defining the input file format
- Call the setLoadFormat() method to set the input file format using the LoadFormat.DOCX class object
- Instantiate the Document class object and load the input Word file with the desired format
- Call the save() method with SaveFormat.XLSX enum to create the Excel file from the loaded Word file
These steps describe how to develop the Word document to Excel converter in Java. Instantiate the LoadOptions class object to define the input file format that is DOCX in the current example. Load the source Word file using the given load options and save the output file as XLSX with SaveFormat.
Code to Convert DOC to XLSX in Java
This code has demonstrated the development of a Word to Excel converter in Java. Note that you can only transform to XLSX format and not the XLS format. However, you may use the input file format from DOC, DOCX, HTML, CHM, MHTML, XML, EPUB, etc.
This article has taught us the conversion of a Word file to an Excel file. To perform Mail Merge for a Word file, refer to the article on Mail Merge in MS Word with Java.