# gantt-exporting

> Gantt chart sample exporting project schedules to PDF and Excel formats.

**Framework:** javascript  **Component:** Gantt  **Variant:** exporting

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/javascript/gantt-exporting.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-gantt
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/gantt-exporting/gantt.html

```html
<div class="control-section">
    <div class="content-wrapper">
        <div id="container">
        </div>
    </div>
</div>
<style>
    .fluent2 #export,
    .fluent2-dark #export,
    .fluent2-highcontrast #export {
        padding: 7px;
    }
</style>
```

### src/components/gantt-exporting/gantt.ts

```typescript
import { Gantt, ExcelExport, Selection, Toolbar, PdfExport, DayMarkers } from '@syncfusion/ej2-gantt';
import type { ClickEventArgs } from '@syncfusion/ej2-navigations';
import { editingData, editingResources } from '../datasource/gantt-data';
/**
 * Exporting Gantt sample
 */
Gantt.Inject(Selection, Toolbar, ExcelExport, PdfExport, DayMarkers);

export function initExportingGantt(): void {
    let gantt: Gantt = new Gantt(
        {
            dataSource: editingData,
            dateFormat: 'MMM dd, y',
            taskFields: {
                id: 'TaskID',
                name: 'TaskName',
                startDate: 'StartDate',
                endDate: 'EndDate',
                duration: 'Duration',
                progress: 'Progress',
                dependency: 'Predecessor',
                parentID: 'ParentId',
                resourceInfo: 'resources'
            },
            columns: [
                { field: 'TaskID', width: 80 },
                { field: 'TaskName', width: 250 }
            ],
            splitterSettings: {
                columnIndex: 2
            },
            allowExcelExport: true,
            allowPdfExport: true,
            toolbar: ['ExcelExport', 'CsvExport', 'PdfExport'],
            toolbarClick: (args?: ClickEventArgs) => {
                if (args.item.id === 'GanttExport_excelexport') {
                    gantt.excelExport();
                } else if (args.item.id === 'GanttExport_csvexport') {
                    gantt.csvExport();
                } else if (args.item.id === 'GanttExport_pdfexport') {
                    gantt.pdfExport();
                }
            },
            allowSelection: true,
            gridLines: 'Both',
            height: '650px',
            rowHeight: 46,
            taskbarHeight: 25,
            treeColumnIndex: 1,
            resourceFields: {
                id: 'resourceId',
                name: 'resourceName'
            },
            resources: editingResources,
            highlightWeekends: true,
            timelineSettings: {
                topTier: {
                    unit: 'Week',
                    format: 'MMM dd, y'
                },
                bottomTier: {
                    unit: 'Day'
                }
            },
            labelSettings: {
                leftLabel: 'TaskName'
            },
            projectStartDate: new Date('03/26/2025'),
            projectEndDate: new Date('09/01/2025')
        });
    gantt.appendTo('#container');
}

```
