importFromExcel
Description
Converts an Excel file to JSON
importFromExcel: (config: any) => void
Parameters
config- (required) object - an 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
note
The method requires HTML5 File API support.
note
This method is defined in the export extension, so you need to activate the export_api plugin. Read the details in the Export/Import for Excel, Export to iCal article.
note
If you use the Gantt version older than 8.0, you need to include the https://export.dhtmlx.com/gantt/api.js on your page to enable the online export service, e.g.:
<script src="codebase/dhtmlxgantt.js"></script>
<script src="https://export.dhtmlx.com/gantt/api.js"></script>
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.
Related API
- exportToExcel
- exportToMSProject
- exportToICal
- exportToPDF
- exportToPNG
- exportToJSON
- importFromMSProject