We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Excel export from gantt control fails with error

Thread ID:

Created:

Updated:

Platform:

Replies:

150952 Jan 25,2020 02:31 PM UTC Jan 28,2020 11:00 AM UTC JavaScript - EJ 2 1
loading
Tags: Gantt Chart
Shaihan
Asked On January 26, 2020 09:36 AM UTC

I am using ASP.NET MVC controller to write a export service for gantt control. UI team is using gantt control of EJS version 1. I am getting the following  exception when trying to export. I have attached sample service code. The data model in service is exactly same as the ui. It's not clear if there is any property mismatch or some settings.

Any help will be appreciated.


Object reference not set to an instance of an object.
   at Syncfusion.EJ.Export.GanttExcelExport.ProcessRecordCell(Object row, GanttColumn column, Boolean indentColumn)
   at Syncfusion.EJ.Export.GanttExcelExport.\u003c\u003ec__DisplayClass36.\u003cProcessRecordRow\u003eb__35(GanttColumn column)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at Syncfusion.EJ.Export.GanttExcelExport.ProcessRecordRow(Object row, Int32 level)
   at Syncfusion.EJ.Export.GanttExcelExport.ProcessHierarchyData(IEnumerable dataSource, Int32 level)
   at Syncfusion.EJ.Export.GanttExcelExport.ProcessGanttContent(IEnumerable dataSource, Int32 level)
   at Syncfusion.EJ.Export.GanttExcelExport.ExecuteResult(GanttProperties ganttModel, IEnumerable dataSource)
   at Syncfusion.EJ.Export.GanttExcelExport.ExportHelper(GanttProperties ganttModel, IEnumerable dataSource)
   at Syncfusion.EJ.Export.GanttExcelExport.Export(GanttProperties ganttModel, IEnumerable dataSource, Boolean multipleExport)
   at SGT5.External.Service.ScheduleExporter.ExportToExcel(String title, SchedulePlanData planData, IReadOnlyList`1 resources)
   at SGT5.Web.Controllers.ExportController.ExportSchedulePlanToExcel(Int32 projectId)
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.\u003cBeginInvokeSynchronousActionMethod\u003eb__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.\u003cInvokeActionMethodFilterAsynchronouslyRecursive\u003eb__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.\u003c\u003ec__DisplayClass46.\u003cInvokeActionMethodFilterAsynchronouslyRecursive\u003eb__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.\u003c\u003ec__DisplayClass21.\u003c\u003ec__DisplayClass2b.\u003cBeginInvokeAction\u003eb__1c()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.\u003c\u003ec__DisplayClass21.\u003cBeginInvokeAction\u003eb__1e(IAsyncResult asyncResult)


Gantt settings in ui


protected readonly staticOptions: EjGanttModel = {
        taskIdMapping: 'id',
        taskNameMapping: 'text',
        startDateMapping: 'start',
        progressMapping: 'completePercentage',
        durationMapping: 'duration',
        resourceInfoMapping: 'resources',
        resourceNameMapping: 'Name',
        resourceIdMapping: 'Id',
        resourceUnitMapping: 'Work',
        predecessorMapping: 'predecessor',
        parentTaskIdMapping: 'parentId',
        endDateMapping: 'finish',
        // notesMapping: 'notesContent',
        taskSchedulingMode: ej.Gantt.TaskSchedulingMode.Auto,
        dayWorkingTime: [{'from': '00:00 AM', 'to':
                this.getWorkingTimeEnd(sg.config.HoursPerManday)}],
        showColumnChooser: true,
        allowColumnResize: true,
        allowSorting: true,
        allowSelection: true,
        enableWBS: true,
        allowGanttChartEditing: true,
        enableProgressBarResizing: true,
        // allowMultiSorting: true,
        enableContextMenu: true,
        enableVirtualization: true,
        connectorlineWidth: 2,
        connectorLineBackground: '#d8d8d8',
        rowHeight: 32,
        taskbarHeight: 24,
        // this part leads to huge delay if false by default
        // includeWeekend: false,
        // this part leads to huge delay if true by default
        // enableCollapseAll: true,
        // this part leads to huge delay
        // enableWBSPredecessor: true,
        // this part leads to huge delay if true
        enablePredecessorValidation:  false,
        showTaskNames: false,
        treeColumnIndex: 2,
        toolbarSettings: {
            showToolbar: true,
            toolbarItems: [
                ej.Gantt.ToolbarItems.Add,
                // ej.Gantt.ToolbarItems.Edit,
                ej.Gantt.ToolbarItems.ExpandAll,
                ej.Gantt.ToolbarItems.CollapseAll,
                ej.Gantt.ToolbarItems.Indent,
                ej.Gantt.ToolbarItems.Outdent,
                ej.Gantt.ToolbarItems.ExcelExport,
                ej.Gantt.ToolbarItems.PdfExport,
                ej.Gantt.ToolbarItems.CriticalPath,
            ],
            customToolbarItems: [
                {
                    templateID: '#linkIn',
                    tooltipText: customToolbarItems.LinkIn
                },
                {
                    templateID: '#linkOut',
                    tooltipText: customToolbarItems.LinkOut
                },
                {
                    templateID: '#ganttZoomIn',
                    tooltipText: customToolbarItems.ZoomIn
                },
                {
                    templateID: '#ganttZoomOut',
                    tooltipText: customToolbarItems.ZoomOut
                }
            ]
        },
        stripLines: [
            {
                day: moment().format('MM/DD/YYYY'),
                label: 'Today',
                lineStyle: 'solid',
                lineColor: '#f3ae3a',
                lineWidth: '2'
            }
        ],
        editSettings: {
            allowEditing: true,
            allowAdding: true,
            allowDeleting: true,
            allowIndent: true,
            editMode: 'cellEditing'
        },
        selectionMode: ej.Gantt.SelectionMode.Cell,
        selectionType: ej.Gantt.SelectionType.Multiple,
        isResponsive: true
    };

I have tried solutions give in KB's but no solution.


Attachment: GanttExport_30ec034e.zip

Jesus Arockia Sankaran S [Syncfusion]
Replied On January 28, 2020 11:00 AM UTC

Hi Shaihan, 
 
We have analyzed your query. When the columns bound to the Gantt are not defined in the Gantt dataSource, and are passed to the exporting method in Code behind, a null exception is thrown as you mentioned. Then we suspected that, finish field which was mapped to endDateMapping is not defined in the dataSource, Hence the issue occurs. Please find the code snippet below, 
Index.cshtml 
//….. 
$("#TreeGridContainer").ejGantt({ 
   //….. 
  endDateMapping: 'finish', 
}); 
 
HomeController.cs 
//….. 
public class HomeController : Controller 
{ 
   public class ScheduleTask 
 { 
      //….. 
    public DateTime? finish { get; set; } 
   } 
} 
 
We have prepared sample in working state with above code. Please find the sample from below link, 
 
Please get back to us, if you need any further assistance on this. 

Regards, 
Jesus Arockia Sankaran S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon