importFromExcel

converts an Excel file to JSON

void importFromExcel(object config);

Parameters

configobjectan object with configuration properties of an imported file

Example

gantt.importFromExcel({
    server:"https://export.dhtmlx.com/gantt",
    data: file,
    callback: function(project){
        console.log(project)
    }
});

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/Import for Excel, Export to iCal article.

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

  • server - sets the API endpoint for the request. Can be used with the local install of the import service. The default value is https://export.dhtmlx.com/gantt.
  • data - an instance of File which should contain an Excel (xlsx) file.
  • callback - a callback function.
  • sheet - the number of the sheet of the document that should be returned by the import service.

Response

The response will contain a JSON with an array of objects:

[
   { "Name": "Task Name", "Start": "2018-08-11 10:00", "Duration": 8 },
   ...
]

where:

  • Values of the first row are used as property names of imported objects.
  • Each row is serialized as an individual object.
  • Date values are serialized in the "%Y-%m-%d %H:%i" format.
See also
Back to top