Having trouble getting help?
Contact Support
Contact Support
Excel export in Vue Gantt component
11 Jun 20245 minutes to read
Gantt supports client-side exporting, which allows you to export its data to the Excel and CSV formats. Use the excelExport
and csvExport
methods for exporting. To enable Excel export in the Gantt, set the allowExcelExport
to true.
To get a configured Gantt chart Exporting, you can follow the steps outlined in the video linked below:
To export data to Excel and CSV, inject the ExcelExport
module in Gantt.
<template>
<div>
<ejs-gantt ref='gantt' id="GanttContainer" :dataSource="data" :taskFields="taskFields" :toolbar="toolbar" :toolbarClick="toolbarClick" :allowExcelExport='true' :height="height"></ejs-gantt>
</div>
</template>
<script setup>
import { provide, ref } from "vue";
import { GanttComponent as EjsGantt, Toolbar, ExcelExport, Selection } from "@syncfusion/ej2-vue-gantt";
import { ClickEventArgs } from '@syncfusion/ej2-navigations';
import { ganttData } from './data-source.js';
const gantt = ref(null);
const data = ganttData;
const height = '450px';
const taskFields = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
child: 'subtasks'
};
const toolbar = ['ExcelExport', 'CsvExport'];
const toolbarClick = (args) => {
if (args.item.id === 'GanttContainer_excelexport') {
var excelExportProperties = {
dataSource: ganttData[1]
};
var ganttObj = gantt.value.ej2Instances;
ganttObj.excelExport(excelExportProperties);
}
};
provide('gantt', [Toolbar, ExcelExport]);
</script>
<template>
<div>
<ejs-gantt ref='gantt' id="GanttContainer" :dataSource="data" :taskFields="taskFields" :toolbar="toolbar" :toolbarClick="toolbarClick" :allowExcelExport='true' :height="height"></ejs-gantt>
</div>
</template>
<script>
import { GanttComponent, Toolbar, ExcelExport, Selection } from "@syncfusion/ej2-vue-gantt";
import { ClickEventArgs } from '@syncfusion/ej2-navigations';
import { ganttData } from './data-source.js';
export default {
name: "App",
components: {
"ejs-gantt":GanttComponent
},
data: function() {
return{
data: ganttData,
height:'450px',
taskFields: {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
child: 'subtasks'
},
toolbar: ['ExcelExport', 'CsvExport'],
toolbarClick: (args) => {
if (args.item.id === 'GanttContainer_excelexport') {
var ganttObj = document.getElementById('GanttContainer').ej2_instances[0];
ganttObj.excelExport();
} else if(args.item.id === 'GanttContainer_csvexport') {
var ganttObj = document.getElementById('GanttContainer').ej2_instances[0];
ganttObj.csvExport();
}
},
};
},
provide: {
gantt: [Toolbar, ExcelExport]
}
};
</script>