Assigning Columns for Gantt Chart Excel Export File

Hi Syncfusion Team,

I have another query regarding the Gantt chart Excel export feature.

How do I assign columns that I want to include on the Gantt chart Excel export file? By default, the export file will include all the column fields that are defined for the Gantt chart. However, I want to hide fields defined from the Gantt chart to the export file to be generated.

While playing around with the ExportProperties class, I saw this Columns property which to my understanding allows us to define what columns we are including for the Export file. However, the Columns property only accepts a List<GridColumn> value. How can I assign my selected columns to ExportProperties.Columns property.

Here's my code so far...

var exportProperties = new Syncfusion.Blazor.Grids.ExcelExportProperties();

      exportProperties.FileName = $"ProjectCalendar_{DateTime.Now.ToString("yyyyMMddhhmmss")}.xlsx";

      exportProperties.Columns = ?;


      await Gantt.ExportToExcelAsync(exportProperties);

Please advise.

Thanks!


3 Replies 1 reply marked as answer

MS Monisha Sivanthilingam Syncfusion Team September 13, 2021 11:56 AM UTC

Hi Denzel, 
 
Greetings from Syncfusion support. 
 
We can use the exportProperties.Columns property to export the specific columns you want to the Excel file. The following code snippets demonstrate the solution. 
 
Index.razor 
 
public async Task ExportCalendarToExcel() 
{ 
  var exportProperties = new Syncfusion.Blazor.Grids.ExcelExportProperties(); 
  exportProperties.FileName = $"ProjectCalendar_{DateTime.Now.ToString("yyyyMMddhhmmss")}.xlsx"; 
  List<GridColumn> ExportColumns = new List<GridColumn>(); 
  ExportColumns.Add(new GridColumn() { Field = "TaskName", HeaderText = "Task Name", Width = "100" }); 
  exportProperties.Columns = ExportColumns; 
 
  await Gantt.ExportToExcelAsync(exportProperties); 
} 
 
 
We have prepared a sample for your reference. 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 


Marked as answer

RS Roy Sunga replied to Monisha Sivanthilingam September 13, 2021 03:10 PM UTC

Thank you Monisha. This is really helpful. I was able to define the columns that I want to appear on my export file in Excel.


Again, many thanks for your response!



MS Monisha Sivanthilingam Syncfusion Team September 14, 2021 05:11 AM UTC

Hi Denzel, 
 
You are welcome. 
 
We are glad that the provided solution worked for you. 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 


Loader.
Up arrow icon