MspExport

A feature that allows exporting Gantt to Microsoft Project without involving a server.

Microsoft Project XML specification

This feature supports exporting to an XML format that can be imported by MS Project Professional 2013 / 2019.

Here is an example of how to add the feature:

const gantt = new Gantt({
    features : {
        mspExport : {
            // Choose the filename for the exported file
            filename : 'Gantt Export'
        }
    }
});

And how to trigger an export:

gantt.features.mspExport.export({
    filename : 'Gantt Export'
})

Processing of exported data

Use the dataCollected event to process exported data before it is written to the XML-file:

// set listener on Gantt construction step
const gantt = new Gantt({
    ---
    features : {
        mspExport : {
            listeners : {
                dataCollected : ({ data }) => {
                    // patch <Project><Name> tag content
                    data.Name = 'My Cool Project';
                }
            }
        }
    }
});

// set listener at runtime
gantt.features.mspExport.on({
    dataCollected : ({ data }) => {
        // patch <Project><Name> tag content
        data.Name = 'My Cool Project';
    }
})

This feature is disabled by default. For info on enabling it, see GridFeatures.

Configs

14

Common

disabledInstancePlugin
listenersEvents

Other

dateFormat: String= YYYY-MM-DDTHH:mm:ss

Defines how dates are formatted for MS Project. Information about formats can be found in DateHelper

filename: String

Name of the exported file (including extension)

msProjectVersion: Number= 2019

Defines the version used for MSProject (2013 or 2019)

Specify true to replace commas in resource names with semicolons.

timeFormat: String= HH:mm:ss

Defines how time is formatted for MSProject. Information about formats can be found in DateHelper

Misc

clientInstancePlugin
localeClassLocalizable
localizableLocalizable

Properties

15

Common

disabledInstancePlugin

Class hierarchy

isMspExport: Boolean= truereadonly
Identifies an object as an instance of MspExport class, or subclass thereof.
isMspExport: Boolean= truereadonlystatic
Identifies an object as an instance of MspExport class, or subclass thereof.
isEventsEvents
isInstancePluginInstancePlugin
isLocalizableLocalizable

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Other

Functions

29

Other

Generates and downloads the .XML file.

ParameterTypeDescription
configObject

Optional configuration object, which overrides the initial settings of the feature/exporter.

config.filenameString

The filename to use

LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Events

8

Fires on the owning Gantt before export starts. Return false to cancel the export.

// Adding a listener using the "on" method
mspExport.on('beforeMspExport', ({ config }) => {

});
ParameterTypeDescription
configObject

Export config

Fires when project data is collected to an object that is going to be exported as XML text.

The event can be used to modify exported data before it is written to the XML-file:

const gantt = new Gantt({
    ---
    features : {
        mspExport : {
            listeners : {
                // listener to process exported data
                dataCollected : ({ data }) => {
                    // patch <Project><Name> tag content
                    data.Name = 'My Cool Project';
                }
            }
        }
    }
});
// Adding a listener using the "on" method
mspExport.on('dataCollected', ({ config, data }) => {

});
ParameterTypeDescription
configObject

Export config

dataObject

Collected data to export

Fires on the owning Gantt when project content is exported to XML, before the XML is downloaded by the browser.

// Adding a listener using the "on" method
mspExport.on('mspExport', ({ config, fileContent }) => {

});
ParameterTypeDescription
configObject

Export config

fileContentString

Exported XML-file content

catchAllEvents
destroyEvents
disableInstancePlugin
enableInstancePlugin

Event handlers

8

Called on the owning Gantt before export starts. Return false to cancel the export.

new MspExport({
    onBeforeMspExport({ config }) {

    }
});
ParameterTypeDescription
configObject

Export config

Called when project data is collected to an object that is going to be exported as XML text.

The event can be used to modify exported data before it is written to the XML-file:

const gantt = new Gantt({
    ---
    features : {
        mspExport : {
            listeners : {
                // listener to process exported data
                dataCollected : ({ data }) => {
                    // patch <Project><Name> tag content
                    data.Name = 'My Cool Project';
                }
            }
        }
    }
});
new MspExport({
    onDataCollected({ config, data }) {

    }
});
ParameterTypeDescription
configObject

Export config

dataObject

Collected data to export

Called on the owning Gantt when project content is exported to XML, before the XML is downloaded by the browser.

new MspExport({
    onMspExport({ config, fileContent }) {

    }
});
ParameterTypeDescription
configObject

Export config

fileContentString

Exported XML-file content

onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin

Typedefs

1