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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Error by Export to Excel

Thread ID:

Created:

Updated:

Platform:

Replies:

131824 Jul 28,2017 01:31 PM UTC Aug 3,2017 10:16 AM UTC ASP.NET Web Forms 3
loading
Tags: Gantt
Martin Sickel
Asked On July 28, 2017 01:31 PM UTC

Dear All

If I try to Export the Gantt to Excel I face the following Error

An exception of type 'System.InvalidCastException' occurred in Syncfusion.EJ.Export.dll but was not handled in user code
Additional information: Specified cast is not valid.


Here the Code I use to make the Export:

            ExcelExport exp = new ExcelExport();
            GanttExportSettings settings = new GanttExportSettings();
            settings.Theme = ExportTheme.FlatSaffron;
            settings.Unicode = true;
            settings.IsFitToWidth = true;
            exp.Export(this.GanttControlDefault.Model, (IEnumerable) this.GanttControlDefault.DataSource, "Resource Planner.xlsx", ExcelVersion.Excel2010, new           GanttExportSettings() { Theme = ExportTheme.FlatLime });

Export to PDF works as expected after I set Localisation of Gantt to de-DE here the Code as well:
            var exp = new PdfExport();
            var settings = new GanttPdfExportSettings();
            settings.EnableFooter = true;
            settings.ProjectName = "Project Tracker";
            settings.Locale = e.Arguments["locale"].ToString();
            settings.Theme = GanttExportTheme.FlatSaffron;
            settings.IsFitToWidth = true;
            exp.Export(GanttControlDefault.Model, (IEnumerable) GanttControlDefault.DataSource, settings, fileName: "Resource Planner");

Can you advise how to solve the Eroor in Excel export?

Martin



Jayakumar Duraisamy [Syncfusion]
Replied On July 31, 2017 01:15 PM UTC

Hi Martin, 
We regret for the inconvenience caused. 
We have analyzed the reported issue in our sample but we couldn’t able to reproduce the issue. Hence, can you please share your demo sample which can be reproduce the reported issue. 
It will helpful for us to serve you better. 
Regards, 
Jayakumar D 


Martin Sickel
Replied On August 2, 2017 05:55 AM UTC

Dear Jayakumar 

I was able to break it down to the Duration Datatype.

This is my Data Model I am using

    public class TaskData

    {

        public int TaskId { get; set; }

        public string TaskName { get; set; }

        public DateTime StartDate { get; set; }

        public DateTime EndDate { get; set; }

        public string Progress { get; set; }

        public string Duration { get; set; }

        public int ParentId { get; set; }

        public List<TaskData> Children { get; set; }

        public List<string> Resources { get; set; }

        public DateTime BaselineStart { get; set; }

        public DateTime BaselineEnd { get; set; }

        public string Predecessors { get; set; }

        public string Work { get; set; }

    }

By changeing the "Duration" datatype to integer, Excel Export is working as expected. But this will bring me to a different issue.

As I am able to change the duration value to half days (8.5 as an example), what seems to be supported, I am not able to use Excel Export anymore,

I have tryed different datatypes, but the only which seems to be supported is the integer datatype.

Is there a workaround for it that I am able to use string or double or decimal as well?

Best Regards

Martin



Jayakumar Duraisamy [Syncfusion]
Replied On August 3, 2017 10:16 AM UTC

Hi Martin, 
We regret for the inconvenience caused. 
We able to reproduce the reported issue when duration data member has string or double type. Hence, we have logged a bug report as “Excel export doesn't support duration value as decimal format. Also, we have created a support incident under your account to track the status of this issue. 
Please log on to our support website to check for further updates. 
Please let us know if you require further assistance on this. 
Regards, 
Jayakumar D 


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.

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

;