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. Image for the cookie policy date
close icon

Error on export

Hi,

I am trying to export charts to excel using code similar to the following :

ExcelExport exp = new ExcelExport();
exp.Export(this.Chart1.Model, (IEnumerable)Chart1.DataSource, "Export.xlsx", ExcelVersion.Excel2010, null, null);

But, In my code, the first parameter of the Export function is of the type Syncfusion.Javascript.DataVisualization.Models.GridProperties, and 
the Chart.Model attribute is of the type Syncfusion.Javascript.DataVisualization.Models.ChartProperties. So, in runtime, it throws a InvalidCastException.

1 Reply

SK Sanjith Kesavan Syncfusion Team March 24, 2016 12:57 PM UTC

Hi Artur,

Thanks for contacting Syncfusion support. We have analyzed your query and code example. For exporting the chart into excel format, in export function you have to give chart parameters only. Using the export method of the chart, we cannot export the grid into excel format and so it shows the exception. If we pass the chart parameters the export function, export to excel is working fine without showing any exception. Please follow the below screenshot



Could you please provide us the following information.

1.       Why did you use grid parameters in the export method instead of chart parameters

2.       Do you want to export the grid into excel format
This information will be helpful for us to proceed further.

In the below link, we have attached sample for your reference.
Sample link: https://www.syncfusion.com/downloads/support/forum/123507/ze/Excel_export1879906251


Regards,
Sanjith.


Loader.
Live Chat Icon For mobile
Up arrow icon