Export to MS Project on the node js servers

Hey there,

We have purchased the enterprise license, and the gantt nodejs server module separately. We wish to export a gantt to MS Project via the server. But it seems that the exportToMsProject function is not available on the nodejs server version of the gantt lib.

Am I missing anything? should it be available? Can I make the request to the export service by myself without the nodejs lib?

Thanks in advance for your help.

Hello,
There are 2 versions of Gantt:

  1. Gantt that you can only run inside the browser. You can add it to an HTML page or use it in React, Angular, Vue.
  2. Gantt for node.js that you can only run on the server.

Both versions themselves cannot convert the data to MS Project or PDF files.
To use the import and export functionality, you need to connect the export’s api.js file:
https://docs.dhtmlx.com/gantt/desktop__export_msproject.html
http://export.dhtmlx.com/gantt/api.js
This file has functions that depend on the browser, so, it won’t work in the node.js environment out of the box.
I tried to modify the code in the file, but it seems that some internal Gantt methods would require the browser functions. I will let the dev team know about it, but I cannot give you any ETA on when it is going to be fixed.

You can manually send the request to the export server, but you need to send it in a specific format. Unfortunately, we don’t have ready guides on how to do that.

However, if you have the PDF export module, which is a node.js application and you want to export the data using your server, the PDF export module doesn’t have that functionality. For that purpose, you need to use the MSP Export module that can only run on the Windows platform.

Many thanks Ramil!

Looking at the api code you’ve mentioned it seems that it is indeed intended to work in a browser. It creates a form element and injects it to the DOM. It might be possible to get it work using a virtual dom package for NodeJS but seems a bit of a long shot. It’s probably possible to get it to work using puppeteer but the overhead of using a headless browser seems a bit of an overkill.

I’ll try to send a request to the export service and get it to work that way.

Thanks again.

Hello,
The dev team is in the process of adding the import and export functionality for the gantt_node package.
If you want to test it, you can use the following file:
https://files.dhtmlx.com/30d/099ae82449593df43ef02926ecae6b49/api.js
You will need to include its contents near the Gantt configuration.

To import the data, you will need to install an additional component:

npm install form-data

I have the following demo that demonstrates the import and export functionality in a node.js application with Gantt:
https://files.dhtmlx.com/30d/bc7c2a27539471fe08529bd16cc8f0bd/gantt_node_export_demo.zip