Skip to content

Instantly share code, notes, and snippets.

@blog-aspose-cloud
Last active October 31, 2023 01:59
Convert MPP to Excel

Convert MPP to Excel (XLS, XLSX) with .NET REST API


Explore the seamless and robust methods to convert MS Project (MPP) to Excel using Aspose.Tasks Cloud SDK for .NET. Transform MS Project files (MPP) to Excel (XLS, XLSX) conversion for better reporting or analysis.

For further details, please visit MS Project (MPP) to Excel (XLS) Conversion with .NET REST API.

Microsoft Project to Excel online

Important Links

Home | Product Page | Docs | API Reference | Cloud Dashboard | Code Samples | Source Code | Blog | Free Support | Free Trial

Learn how to convert MS Project File (MPP) to Excel (XLS, XLSX) with .NET REST API
// For more examples, please visit https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet
// Get client credentials from https://dashboard.aspose.cloud/
string clientSecret = "4d84d5f6584160cbd91dba1fe145db14";
string clientID = "bb959721-5780-4be6-be35-ff5c3a6aa4a2";
// create TasksApi instance
TasksApi tasksApi = new TasksApi(clientSecret, clientID);
// Name of input MPP file
String inputFile = "Home move plan.mpp";
// name of resultant HTML file
String resultant = "resultant.xlsx";
// SaveOptions parameters is a json-serialized representation of
// Aspose.Tasks's SaveOptions class or its format-specific inheritors (Like CsvOptions, etc):
var saveOptionsSerialized = "{ \"TextDelimiter\":\"Comma\", \"IncludeHeaders\":false,\"NonExistingTestProperty\":false," +
"\"View\":{ \"Columns\":[{Type:\"GanttChartColumn\",\"Name\":\"TestColumn1\",\"Property\":\"Name\",\"Width\":120}," +
"{Type:\"GanttChartColumn\",\"Name\":\"TestColumn2\",\"Property\":\"Duration\",\"Width\":120}]}}";
// Populate JObject from string instance containing JSON
var saveOptions = JObject.Parse(saveOptionsSerialized);
// call the API to convert MPP to XLSX format using SaveOptions instance
var finalResponse = tasksApi.PostTaskDocumentWithFormat(new PostTaskDocumentWithFormatRequest()
{
SaveOptions = saveOptions,
Format = ProjectFileFormat.Xlsx,
Name = inputFile,
ReturnAsZipArchive = false
});
// save the resultant Excel worksheet to local drive
saveToDisk(finalResponse, resultant);
// Method to save stream content to file on local drive
public static void saveToDisk(Stream responseStream, String resultantFile)
{
var fileStream = File.Create(resultantFile);
responseStream.Seek(0, SeekOrigin.Begin);
responseStream.CopyTo(fileStream);
fileStream.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment