Microsoft Project Export
There is built in support for exporting the gantt contents into MS Project compatible XML that can be opened in Project.
This is illustrated in the sample:
<install path>\Samples\ProjectGantt\DataBinding\GanttControlExportToProjectXML
To export the contents of a gantt into Project XML, you can create a Project document from an empty Project XML in memory and add tasks and resources as shown below:
Project project = Project.FromStream(this.GetFileStream(path));
project.InitFrom(this.ganttControl.Model);
foreach (IActivityView view in this.ganttControl.ActivityViews)
{
ProjectTask pt = ...;// Create from IActivity
project.Tasks.Add(pt);
....
}
project.SaveTo(fileStream);
The full source can be seen in the sample above.
Microsoft Project Import
MS Project XML format contains a whole lot of features, not all of which are used by / compatible with the gantt. When you try to import a Project XML into the gantt, you can expect to see the following information imported and the rest ignored:
Task Specific Information
APIs allow you to open a stream of Project XML files, create a Project Document in memory and initialize a gantt from this as shown below.
This is also illustrated in the sample <install path>\Samples\ProjectGantt\DataBinding\GanttControlMSProjectXMLBinding
this.project = Project.FromStream(stream);
// Turn these off for better performance while loading.
this.ganttControl.ValidateDependencySetting = false;
this.ganttControl.EnforceDependencyConstraints = false;
if (project.BaseCalendar == null)
this.ganttControl.WorkTimeSchedule = null;
else
this.ganttControl.WorkTimeSchedule = project.BaseCalendar.Schedule;
this.ganttControl.ResourceItemsSource = project.ResourceList;
using (new DelayUpdates())
{
this.ganttControl.ItemsSource = project.Tasks;
}
Take a look at the above sample for a fully functional example.
� RadiantQ 2009 - 2019. All Rights Reserved.