Exporting and Importing Data
dhtmlxGantt can export a chart to PDF, PNG, Excel, iCal, MS Project, Primavera P6, and JSON files, and import data from Excel, MS Project, and Primavera P6 files. All file export and import goes through an export service: either the online export service hosted by DHTMLX, or an export module that you install on your own server.
In this documentation:
- export service is the software that converts Gantt data to a file or a file to Gantt data;
- online export service is the instance of the export service that DHTMLX runs at
https://export.dhtmlx.com; - export module is an export service that you install and run yourself.
What you can export and import
| Format | Export | Import | Methods | Export module | Guide |
|---|---|---|---|---|---|
| Yes | - | exportToPDF() | PDF/PNG/Excel module | PDF and PNG | |
| PNG | Yes | - | exportToPNG() | PDF/PNG/Excel module | PDF and PNG |
| Excel | Yes | Yes | exportToExcel(), importFromExcel() | PDF/PNG/Excel module | Excel |
| iCal | Yes | - | exportToICal() | PDF/PNG/Excel module | iCal |
| MS Project | Yes | Yes | exportToMSProject(), importFromMSProject() | MS Project/P6 module | MS Project |
| Primavera P6 | Yes | Yes | exportToPrimaveraP6(), importFromPrimaveraP6() | MS Project/P6 module | Primavera P6 |
| JSON file | Yes | - | exportToJSON() | PDF/PNG/Excel module | - |
| JSON or XML in the page | Yes | - | serialize() | not needed, runs in the browser | JSON and XML |
To export and import data on the server side, see Export and Import Data on Node.js.
How export works
- You enable the
export_apiplugin with the plugins method and call an export or import method, for example,gantt.exportToPDF(). - The method sends the Gantt data to an export service in a POST request.
- The export service creates the file, or reads the imported file.
- The browser receives the file. For import, the
callbackfunction of the method receives the data. For export, acallbackfunction can receive a URL of the generated file instead.
When the export service has sent the result, it deletes the temporary files of the request. If you export with a callback function, the export service saves the generated file to give you its URL, so the file stays on the server. The online export service deletes such files after some time. An export module keeps them until you delete them.
By default, all methods send requests to the online export service at https://export.dhtmlx.com/gantt. To send them to another export service, for example, to your own export module, set the server parameter of the method:
gantt.exportToPDF({
server: "https://myapp.com/myexport/gantt"
});
Online export service or your own install
- Watermark. The online export service is free, but the PDF and PNG files that it creates contain a watermark unless you have a valid license and your domain is on the list of licensed domains of the service. See License and watermark.
- Limits. The online export service has time and request size limits. See Online export service limits. An export module that you install has the limits that you configure.
- Data location. The online export service processes your data on DHTMLX servers. With export modules, you can keep the data in your network. See How the two modules work together.
- Setup. The online export service needs no setup. An export module needs a server: Node.js or Docker for the PDF/PNG/Excel module, .NET or Docker for the MS Project/P6 module. See Export Modules.
Online export service limits
The online export service has time and request size restrictions.
Time limits
If the process takes more than 20 seconds, the export will be canceled and the following error will occur:
Error: Page render timeout: 20 seconds. Read more here: https://docs.dhtmlx.com/gantt/guides/export-common/#service-limits
If several people export Gantt at the same time, the process can take more time than usual. But that's fine because the time which is spent for export request from a specific user is counted separately.
Limits on request size
There is a common API endpoint https://export.dhtmlx.com/gantt which serves for all export methods (exportToPDF, exportToPNG, exportToMSProject, etc.). Max request size is 10 MB.
There is also a separate API endpoint https://export.dhtmlx.com/gantt/project specific for the MS Project and Primavera P6 export/import services (exportToMSProject / importFromMSProject / exportToPrimaveraP6 / importFromPrimaveraP6 only). Max request size: 40 MB. See how to use it for MS Project and Primavera P6.
License and watermark
The online export service is free, but the output PDF and PNG files will contain the library's watermark. To export without the watermark you need a valid license - the result of export will be available without a watermark during the valid support period (12 months for all PRO licenses).
A license does not remove the watermark automatically. The online export service removes it only for requests from the domains on its list of licensed domains, so the files that you export from other domains still contain the watermark. After you get a license, send the domains of your application to info@dhtmlx.com and ask us to add them to the list.
Export modules are not included in the Gantt package. An export module is provided free of charge if you've obtained Gantt under Commercial, Enterprise or Ultimate license, or you can buy the module separately. Read the corresponding article to learn the terms of using each of them.