Converting project schedules from Microsoft Project into Excel spreadsheets is a frequent need for reporting and data analysis. Aspose.CAD Cloud SDK for Node.js enables developers to convert MPP to XLSX in Node.JS with just a few lines of code. In this tutorial you will see how to set up the library, upload an MPP file to cloud storage, generate an XLSX task sheet report, and retrieve the result. The guide also provides equivalent cURL commands for REST API users. By the end you’ll be ready to integrate MPP to XLSX conversion into your Node.JS applications.
Full Working Example for Convert MPP to XLSX in Node.JS
This example demonstrates how to upload an MPP file, request an XLSX task‑sheet report, and download the result using the Aspose.Tasks Cloud API.
const path = require('path');
const fs = require('fs');
const {
Configuration,
ApiClient,
TasksApi,
StorageApi
} = require('asposetaskscloud');
(async () => {
// -------------------- Configuration --------------------
const config = new Configuration({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET'
// baseUrl can be set here if needed
});
const apiClient = new ApiClient(config);
const tasksApi = new TasksApi(apiClient);
const storageApi = new StorageApi(apiClient);
// -------------------- File paths --------------------
const localInputPath = path.resolve(__dirname, 'project.mpp');
const remoteFolder = 'Temp';
const remoteFileName = 'project.mpp';
const localOutputPath = path.resolve(__dirname, 'project.xlsx');
try {
// -------------------- Upload MPP to cloud storage --------------------
const fileBuffer = fs.readFileSync(localInputPath);
await storageApi.uploadFile({
path: `${remoteFolder}/${remoteFileName}`,
file: fileBuffer
});
// -------------------- Convert to XLSX (TaskSheet report) --------------------
const reportResponse = await tasksApi.getTaskReport({
name: remoteFileName,
folder: remoteFolder,
reportType: 'TaskSheet', // options: GanttChart, ResourceSheet, etc.
format: 'xlsx'
});
// -------------------- Save XLSX locally --------------------
fs.writeFileSync(localOutputPath, reportResponse.body);
console.log(`Conversion completed. XLSX saved to ${localOutputPath}`);
} catch (err) {
if (err.response && err.response.body) {
console.error('API error:', err.response.body);
} else {
console.error('Unexpected error:', err);
}
} finally {
// -------------------- Cleanup remote file --------------------
try {
await storageApi.deleteFile({ path: `${remoteFolder}/${remoteFileName}` });
} catch (cleanupErr) {
// ignore cleanup errors
}
}
})();
Note: This code example demonstrates the core functionality. Before using it in your project, make sure to update any file paths and configuration values to match your actual environment, verify that all required dependencies are properly installed, and test thoroughly in your development environment. If you encounter any issues, please refer to the official documentation or reach out to the support team for assistance.
Using REST API with cURL for MPP to XLSX Conversion
Below are the cURL commands that perform the same steps as the Node.js code, using the Aspose.Tasks Cloud REST API.
- Obtain an access token - replace
YOUR_CLIENT_IDandYOUR_CLIENT_SECRETwith your credentials.
curl -X POST "https://api.aspose.cloud/v4.0/oauth2/token?grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"
- Upload the source MPP file - store the token from the previous step in
YOUR_ACCESS_TOKEN.
curl -X PUT "https://api.aspose.cloud/v4.0/storage/file/Temp/project.mpp" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary "@project.mpp"
- Request the XLSX task‑sheet report.
curl -X GET "https://api.aspose.cloud/v4.0/tasks/project.mpp/report?reportType=TaskSheet&format=xlsx" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-o project.xlsx
- Download the generated XLSX file (the previous command already saves it locally, but you can also retrieve it directly).
curl -X GET "https://api.aspose.cloud/v4.0/storage/file/Temp/project.xlsx" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-o project.xlsx
For more details on each endpoint, see the official API reference.
How Convert MPP to XLSX in Node.JS Works
The implementation can be broken down into the following steps:
- Configure authentication - The
Configurationobject holdsclientIdandclientSecret.const config = new Configuration({ clientId: 'YOUR_CLIENT_ID', clientSecret: 'YOUR_CLIENT_SECRET' }); - Create API clients -
ApiClientis instantiated with the configuration and passed toTasksApiandStorageApi.const apiClient = new ApiClient(config); const tasksApi = new TasksApi(apiClient); const storageApi = new StorageApi(apiClient); - Upload the MPP file - The file is read into a buffer and sent via
storageApi.uploadFile.const fileBuffer = fs.readFileSync(localInputPath); await storageApi.uploadFile({ path: `${remoteFolder}/${remoteFileName}`, file: fileBuffer }); - Request the XLSX report -
tasksApi.getTaskReportis called withreportType: 'TaskSheet'andformat: 'xlsx'.const reportResponse = await tasksApi.getTaskReport({ name: remoteFileName, folder: remoteFolder, reportType: 'TaskSheet', format: 'xlsx' }); - Save the result locally - The binary response body is written to
project.xlsx.fs.writeFileSync(localOutputPath, reportResponse.body);
These steps illustrate a STEP by STEP Convert Large MPP Files to XLSX in Node.JS workflow that can be adapted for other report types such as GanttChart or ResourceSheet.
Prerequisites and Setup for Aspose.CAD Cloud SDK
- Node.js version - Ensure you are running Node.js 14 or later.
- Install the SDK - Use npm to add the package to your project.
The package is available from the official download page.
npm install @asposecloud/aspose-cad-cloud - Create an Aspose Cloud account - Obtain
clientIdandclientSecretfrom the Aspose Cloud dashboard. - Set up environment variables (optional but recommended) to keep credentials out of source code.
With these prerequisites satisfied, you can run the complete code example shown earlier.
Conversion Options and Settings
The Tasks API offers several parameters that influence the output:
reportType- Determines the kind of data exported. Options includeTaskSheet,GanttChart,ResourceSheet, etc. The example usesTaskSheetto produce a flat task list in XLSX.format- Currently supportsxlsx,pdf,html. Changing this value switches the output file type.folder- Specifies the cloud storage folder where the source MPP resides. Adjust as needed for your project structure.
For a full list of options, refer to the API reference.
Wrapping Up
You now have a complete, production‑ready method to convert MPP to XLSX in Node.JS using the Aspose.CAD Cloud SDK for Node.js. The SDK handles authentication, file storage, and report generation, allowing you to focus on integrating the XLSX data into your business logic. Remember to acquire a proper license for production use; pricing details are available on the product page and you can obtain a temporary license from the temporary license page. Happy coding!
Frequently Asked Questions
Can I convert MPP to XLSX in Node.JS without using Aspose.CAD Cloud SDK?
While a custom parser is possible, Aspose.CAD Cloud SDK for Node.js provides a tested, reliable solution that saves development time and handles edge cases.
What report types are available when converting MPP to XLSX?
The API supports TaskSheet, GanttChart, ResourceSheet, and more. Selecting a different reportType changes the structure of the generated XLSX file.
How do I handle large MPP files during conversion?
Upload large files in chunks using the storage API, monitor the conversion status, and stream the XLSX result to avoid high memory consumption.