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
Configs
14Other
Defines how dates are formatted for MS Project. Information about formats can be found in DateHelper
Name of the exported file (including extension)
Defines the version used for MSProject (2013 or 2019)
Specify true to replace commas in resource names with semicolons.
Defines how time is formatted for MSProject. Information about formats can be found in DateHelper
Misc
Properties
15
Properties
15Common
Class hierarchy
Other
Functions
29
Functions
29Other
Generates and downloads the .XML file.
| Parameter | Type | Description |
|---|---|---|
config | Object | Optional configuration object, which overrides the initial settings of the feature/exporter. |
config.filename | String | The filename to use |
Configuration
Events
Misc
Events
8
Events
8Fires on the owning Gantt before export starts. Return false to cancel the export.
// Adding a listener using the "on" method
mspExport.on('beforeMspExport', ({ config }) => {
});| Parameter | Type | Description |
|---|---|---|
config | Object | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
config | Object | Export config |
data | Object | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
config | Object | Export config |
fileContent | String | Exported XML-file content |
Event handlers
8
Event handlers
8Called on the owning Gantt before export starts. Return false to cancel the export.
new MspExport({
onBeforeMspExport({ config }) {
}
});| Parameter | Type | Description |
|---|---|---|
config | Object | 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
config | Object | Export config |
data | Object | 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
config | Object | Export config |
fileContent | String | Exported XML-file content |