# gantt-exporting

> Gantt chart with toolbar commands for exporting project data to Excel and PDF formats.

**Framework:** aspnet-mvc  **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/aspnet-mvc/gantt-exporting.json
```

**Install Package(s)**

```bash
Install-Package Syncfusion.AspNetMvc.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.cshtml

```cshtml
@using Syncfusion.EJ2
@{
    ViewData["Title"] = "Exporting";
}

@section ControlsSection{
    <div class="control-section">
        <div class="content-wrapper">
            <div>
                @(Html.EJS().Gantt("GanttExport")
                .DataSource((IEnumerable<object>)ViewData["DataSource"])
                .AllowExcelExport(true)
                .AllowPdfExport(true)
                .TaskFields(ts => ts.Id("TaskId").Name("TaskName").StartDate("StartDate").EndDate("EndDate").Duration("Duration")
                    .Progress("Progress").Dependency("Predecessor").Child("SubTasks").ResourceInfo("ResourceId"))
                .Toolbar(new List<string>() { "ExcelExport", "CsvExport", "PdfExport" })
                .AllowSelection(true)
                .GridLines(Syncfusion.EJ2.Gantt.GridLine.Both)
                .Height("450px")
                .Holidays(hol =>
                {
                    hol.From("04/04/2024").To("04/04/2024").Label("Local Holiday").Add();
                    hol.From("04/19/2024").To("04/19/2024").Label("Good Friday").Add();
                    hol.From("04/30/2024").To("04/30/2024").Label("Release Holiday").Add();
                })
                .EventMarkers(em =>
                {
                    em.Day("04/02/2024").Label("Project starts").Add();
                    em.Day("04/09/2024").Label("Design phase").Add();
                    em.Day("04/19/2024").Label("Research phase").Add();
                    em.Day("05/23/2024").Label("Production phase").Add();
                    em.Day("06/20/2024").Label("Sales and marketing phase").Add();
                })
                .TreeColumnIndex(1)
                .ResourceFields(rf => rf.Id("ResourceId").Name("ResourceName"))
                .Resources((IEnumerable<object>)ViewData["Resources"])
                .HighlightWeekends(true)
                .Columns(col =>
                {
                    col.Field("TaskId").Visible(false).Add();
                    col.Field("TaskName").HeaderText("Task Name").Add();
                })
                .TimelineSettings(tl => tl.TopTier(tt =>
                    tt.Unit(Syncfusion.EJ2.Gantt.TimelineViewMode.Week).Format("MMM dd, y")).
                    BottomTier(bt => bt.Unit(Syncfusion.EJ2.Gantt.TimelineViewMode.Day)))
                .LabelSettings(ls => ls.LeftLabel("TaskName"))
                .ToolbarClick("toolbarClick")
                .ProjectStartDate("03/25/2024")
                .ProjectEndDate("07/28/2024")
                .Render()
            )
            </div>
            <style>
                .fluent2 #export,
                .fluent2-dark #export {
                    padding: 7px;
                }
            </style>
            <script>
                function toolbarClick(args) {
                    if (args.item.id === "GanttExport_excelexport") {
                        this.excelExport();
                    }
                    else if (args.item.id === "GanttExport_csvexport") {
                        this.csvExport();
                    }
                    else if (args.item.id === "GanttExport_pdfexport") {
                        this.pdfExport();
                    }
                }
            </script>
        </div>
    </div>
}
```

### src/components/gantt-exporting/GanttController.cs

```cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EJ2MVCSampleBrowser.Models;
namespace EJ2MVCSampleBrowser.Controllers.Gantt
{
    public partial class GanttChartController : Controller
    {
        // GET: Editing
        public ActionResult Exporting()
        {
            ViewData["DataSource"] = GanttData.EditingData();
            ViewData["Resources"] = GanttData.EditingResources();
            return View("~/Views/Home/gantt/exporting/Gantt.cshtml");
        }
    }
}
```
