importFromMSProject

converts an XML or MPP MS Project file to JSON

void importFromMSProject(object config);

Parameters

configobjectan object with configuration properties of an imported file

Example

gantt.importFromMSProject({
    data: file,
    taskProperties: ["Notes", "Name"],
    callback: function (project) {
        if (project) {
            gantt.clearAll();
            if (project.config.duration_unit) {
                gantt.config.duration_unit = project.config.duration_unit;
            }                    
            gantt.parse(project.data);
        }
     }
});

Related samples

Details

The method requires HTML5 File API support.

This method is defined in the export extension, so you need to include it on the page:

<script src="http://export.dhtmlx.com/gantt/api.js"></script>

Read the details in the Export and Import from MS Project article.

The method takes as a parameter an object with configuration properties of an imported file:

  • data - an instance of File which should contain either MPP or XML Project file.
  • callback - a callback function.
  • durationUnit - sets an expected duration unit ("minute", "hour", "day", "week", "month", "year").
  • projectProperties - specifies an array of project properties that should be put into the response.
  • taskProperties - specifies an array of additional task properties to be imported.

Response

The response will contain a JSON of the following structure:

{
   data: {},
   config: {},
   resources: [],
   worktime: {}
}
  • data - a gantt data object. Each task has the following properties: id, open, parent, progress, start_date, text, resource. Dates are stringified in the "%Y-%m-%d %H:%i" format.
  • config - a gantt configuration object with settings retrieved from the project file.
  • resources - an array of objects (each having the following properties: {id:string, name:string, type:string} that represent the list of resources from the project file.
  • worktime - an object containing the working time settings from the project calendar.
See also
Back to top