Convert MPP File to Excel in Java

MPP file
MPP File to Excel Conversion | Convert Microsoft Project File to XLS using Java

One of the popular applications for project management is Microsoft Project as its capable of organizing, tracking, and maintaining project plans. They are used by project managers, stakeholders, and people in the project team. Once you have created tasks, assigned them to resources, and defined their dependencies, you may have a requirement to share the project plan among stakeholders. So in order to view this document, we need to use MS Project Professional or other supporting software. Therefore, we may consider following the steps specified below to convert the MPP file to Excel using Java.

Microsoft Project File Conversion API

Aspose.Tasks Cloud SDK for Java provides the capabilities to create, manipulate and export Microsoft Project file to Excel, HTML, JPEG, PDF, XML, PNG, etc. In order to use the SDK, you may directly download aspose-tasks-cloud.jar or add the following reference to pom.xml in the maven build type project.

<repositories>
    <repository>
        <id>aspose-cloud</id>
        <name>artifact.aspose-cloud-releases</name>
        <url>http://artifact.aspose.cloud/repo</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-tasks-cloud</artifactId>
        <version>21.10.0</version>
    </dependency>
</dependencies>

Furthermore, the next step to use the SDK is to register an account over Aspose.Cloud dashboard using GitHub or Google account or simply Sign Up to obtain your Client Credentials.

Convert MPP File to Excel in Java

Let’s explore the details on how we can load MPP file from cloud storage and export MS Project to excel in the Java application.

  • First, create an instance of ApiClient class while passing your Client ID and Client Secret as constructor arguments
  • Secondly, create an object of TasksApi which takes the ApiClient object as an argument
  • Thirdly, create an object of UploadFileRequest which takes the name of the input MPP file as an argument
  • Call UploadFile(…) method to upload the MPP file to cloud storage
  • The next step is to instantiate an object of GetTaskDocumentWithFormatRequest where we provide the name of the input MPP file and XLSX as the output format
  • Finally, call the method getTaskDocumentWithFormat(…) to convert the MPP file to Excel and save the output to cloud storage

Export Microsoft Project File to Excel using cURL Commands

In this section, we are going to use cURL commands to export the Microsoft Project File to Excel format. The resultant file is downloaded to the local drive. However, before we initialize the conversion operation, we need to generate a JWT access token based on client credentials. Please execute the following command in the terminal application to generate the JWT token:

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now that we have the token, please execute the following command to convert the MPP file available in cloud storage to Excel format.

curl -v -X GET "https://api.aspose.cloud/v3.0/tasks/source.mpp/format?format=xlsx&returnAsZipArchive=false" \
-H  "accept: multipart/form-data" \
-H  "authorization: Bearer <JWT Token>" \
-o Converted.xlsx
MPP file to XLS conversion preview
Image 1:- Microsoft Project file to XLSX conversion preview.

The input MPP file used in the above example can be downloaded from Home_move_plan.mpp and the resultant excel can be downloaded from Converted.xlsx.

Conclusion

This article has explained the steps to convert an MPP file to Excel format using Java Cloud SDK. We have noticed that with a single API call, the whole conversion is performed and we have also explored the flexibility to export Microsoft project file to excel format using cURL commands over the command line terminal. Furthermore, the complete source code of SDK is also available over GitHub and you may modify it as per your requirements.

Related Articles

We highly recommend visiting the following links to learn about