Free Support Forum - aspose.com

Render Project Data to HTML in C#

A Microsoft Project (.mpp) file can be opened with Microsoft Project. However, it is not helpful in situation where you can’t share the actual files, or you have to present project plan. The plan can also be required to be published on a website. In such scenarios, it’s very important to convert project plan to HTML format. Aspose.Tasks for .NET allows you to convert and render a project plan to HTML in your C# code. You can also specify a variety of attributes for the output HTML format.

Steps to Render Project Data to HTML

  1. First, install Aspose.Tasks for .NET from NuGet and get temporary license
  2. Create an object of Project class and load the input .mpp file
  3. Create an object of HtmlSaveOptions
  4. Specify your required output attributes and options
  5. Save the output HTML file.

C# Code to Save Project Data as HTML with Default Attributes

//set license 
Aspose.Tasks.License license = new Aspose.Tasks.License();
license.SetLicense(@"C:\licenses\license.lic");

//create object of Project class
Aspose.Tasks.Project project = new Aspose.Tasks.Project(@"C:\files\project_plan_sample.mpp");
 project.Save(@"C:\files\project_plan_sample.html", Aspose.Tasks.Saving.SaveFileFormat.HTML);

Render Project Data to HTML in C# with Custom Attributes

//set license 
 Aspose.Tasks.License license = new Aspose.Tasks.License();
license.SetLicense(@"C:\licenses\license.lic");

//create object of Project class
Aspose.Tasks.Project project = new Aspose.Tasks.Project(@"C:\files\project_plan_sample.mpp");

//set save options to output project data as HTML
Aspose.Tasks.Saving.HtmlSaveOptions saveOptions = new Aspose.Tasks.Saving.HtmlSaveOptions();

//specify bar style of the bars in the output HTML file
Aspose.Tasks.Visualization.BarStyle barStyle = new Aspose.Tasks.Visualization.BarStyle();
barStyle.BarColor = System.Drawing.Color.Blue;
barStyle.BarShape = Aspose.Tasks.Visualization.BarShape.Full;
List<Aspose.Tasks.Visualization.BarStyle> list = new List<Aspose.Tasks.Visualization.BarStyle>();
list.Add(barStyle);
saveOptions.BarStyles = list;
//set page size of your choice depending upon your need
saveOptions.PageSize = Aspose.Tasks.Visualization.PageSize.A2; 

//save output file with the specified save options
project.Save(@"C:\files\project_plan_sample.html", saveOptions);

For any further questions or help related to Aspose.Tasks for .NET, please feel free to post your questions in Aspose.Tasks Product Family free support forums.