excel to word

Convert Excel to Word in Java

As Excel workbooks is one of the de facto file formats for storing, analyzing, and reporting on reasonable set of data. It is often used by accounting teams for financial analysis, organizing data, time tracking etc. However, Excel is not designed for collaborative work and is vulnerable to fraud/corruption. Also, its hard to tell who edited the spreadsheet. So its conversion to Word document can be a viable solution. One of the advantages of using Microsoft Word is that it is available practically everywhere. Furthermore, Instant Help, Navigation Pane, Document Flexibility etc are among the salient features of MS Word document. In this article, we are going to discuss the details on how to convert Excel to Word document using REST API.

Excel to Word Conversion API

In order to convert Excel to Word, we are going to use Aspose.Cells Cloud SDK for Java. Its REST based API offering the capabilities to create, edit, convert Excel to PDF, Excel to JPG, Excel to HTML, and other Supported File Formats. We need to create maven build type project and add the following details in pom.xml file.

        <name>Aspose Java API</name>

The next important step is to create an account over Aspose Cloud and lookup/create Client ID and Client Secret at Cloud Dashboard.

Convert Excel to Word in Java

In this section, we are going to discuss the steps on how to convert Excel to Word document using java code snippet. Please note that we are going to read an excel worksheet from local drive and after the conversion, the resultant Word document will be saved in Cloud storage.

  • Create an instance of CellsApi while providing client credentials as input arguments
  • Specify the name of input Excel, resultant format as HTML, and output file name
  • Read Excel file from local storage through File instance
  • Finally, call the method cellsWorkbookPutConvertWorkbook(…) for Excel image conversion operation
excel to Word preview

image 1:- Excel to Word Conversion preview

You may consider downloading the input Excel workbook used in above example from myDocument.xlsx.

Export Excel to Word using cURL Commands

We can also export Excel to Word document using cURL commands. So as a pre-requisite, we need to first generate a JWT access token while executing the following command.

curl -v "https://api.aspose.cloud/connect/token" \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now that we have our personalized JWT token, we need to execute the following command to export Excel to Word document. The resultant DOCX is stored in cloud storage.

curl -v -X GET "https://api.aspose.cloud/v3.0/cells/myDocument.xlsx?format=DOCX&isAutoFit=true&onlySaveTable=true&outPath=Resultant.docx&checkExcelRestriction=true" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"
Export Excel to Word

Image 2:- Excel to Word conversion preview


This article has explored the details on how to convert Excel to Word using Java code snippets. We have also learned the details on how to export Excel to Word using cURL Commands. Please note that our SDKs are built under an MIT license, so the complete source code can be downloaded from GitHub. In case you encounter any issues while using the APIs, please feel free to contact us via free product support forum.

We highly recommend visiting the following links to learn more about: