Save mpp file with default view as Gannt task view


#1

Hi Team,
Am looking for options to save a MPP file using

ProjectSave(“FilePath”, new MPPSaveOptions() { WriteViewData = true });

with default view set as Gantt view and zoom to “Entire project” always.
Please let me know the options with aspose to achieve this.

Thank you.


#2

@Rajeshrv

Please try the following code sample:

GanttChartView view = (GanttChartView)project.DefaultView;
            
// This code is added for better visualization
view.MiddleTimescaleTier.Unit = TimescaleUnit.Days; 

You can apply different TimescaleUnits as per your requirements.


#3

GanttChartView view = (GanttChartView)project.DefaultView;

  • Throws exception when I have DefaultView as ResourceView, so wanted to know how to set default view as Gantt chart view.

view.MiddleTimescaleTier.Unit = TimescaleUnit.Days;

  • For my use case I wanted to set it as Quarters, but same is not being set in the saved MPP file.

#4

@Rajeshrv

Can you please mention what kind of exception is thrown.
Moreover, we have logged an issue with issue ID “TASKSNET-2737” for further investigation while using Quarters as TimescaleUnit. You will automatically be informed here once we have more information to share.


#5

Here is the exception up on type casting

System.InvalidCastException: ‘Unable to cast object of type ‘Aspose.Tasks.View’ to type ‘Aspose.Tasks.GanttChartView’.’


#6

@Rajeshrv

We have logged these details under issue ID “TASKSNET-2737” and will be considered during the issue resolution.