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

Error while exporting grid

Thread ID:

Created:

Updated:

Platform:

Replies:

146747 Aug 17,2019 05:59 AM UTC Aug 19,2019 05:23 PM UTC ASP.NET MVC 1
loading
Tags: Grid
CLAUDIO RICCARDI
Asked On August 17, 2019 05:59 AM UTC

Hi.

I have the following grid:

@(Html.EJ().Grid<SlimHub.ViewModels.InvoiceCompetenceVM>
("InvoicesGrid")
.Datasource(ds => ds.Json((IEnumerable<SlimHub.ViewModels.InvoiceCompetenceVM>)Model))
.AllowMultiSorting()
.AllowFiltering()
.AllowSelection()
.AllowSorting()
.AllowGrouping()
.EnableHeaderHover()
.AllowResizing()
.AllowTextWrap(true)
.Locale("it-IT")
.GroupSettings(x => x.GroupedColumns(xf => { xf.Add("CompetenceYear"); }))
.ShowSummary()
.SummaryRow(row =>
{
row.Title("Totale Comp.").SummaryColumns(col => { col.SummaryType(SummaryType.Sum).Format("{0:C}").DisplayColumn("CompetenceAmount").DataMember("CompetenceAmount").Add();}).Add();
})
.FilterSettings(filter => { filter.FilterType(FilterType.Excel);})
.ToolbarSettings(toolBar => toolBar.ShowToolbar().ToolbarItems(items=>
{
items.AddTool(ToolBarItems.ExcelExport);
items.AddTool(ToolBarItems.WordExport);
items.AddTool(ToolBarItems.PdfExport);
}))
.Columns(col =>
{
col.Type("checkbox").Width(50).Add();
col.Field("InvoiceId").HeaderText("IDFattura").TextAlign(TextAlign.Center).Width(0).Visible(false).Add();
col.Field("InvoiceCode").HeaderText("Codice").TextAlign(TextAlign.Center).Width(200).Visible(true).Add();
col.Field("InvoiceYear").HeaderText("Anno").TextAlign(TextAlign.Center).Width(50).Visible(false).Add();
col.Field("InvoiceMonth").HeaderText("Mese").TextAlign(TextAlign.Center).Width(50).Visible(false).Add();
col.Field("CompetenceYear").HeaderText("AnnoComp.").TextAlign(TextAlign.Center).Width(50)Visible(true).Add();
col.Field("InvoiceNum").HeaderText("Num").TextAlign(TextAlign.Center).Width(50).Add();
col.Field("InvoiceSecondaryNum").HeaderText("Num").TextAlign(TextAlign.Center).Width(50).Add();
col.Field("CustomerName").HeaderText("Cliente").TextAlign(TextAlign.Center).Width(250).Add();
col.Field("CompetenceAmount").HeaderText("Tot.Competenza").TextAlign(TextAlign.Right).Format("{0:c2}").Width(85).Add();
})
.ClientSideEvents(eve =>
{
eve.RecordDoubleClick("onInvoiceRecordDoubleClick");
})
)

//VIEMODEL

namespace SlimHub.ViewModels
{
public class InvoiceCompetenceVM
{
public int InvoiceId { get; set; }

public string InvoiceCode { get; set; }

public int InvoiceYear { get; set; }

public int InvoiceMonth { get; set; }

public int CompetenceYear { get; set; }

public int? InvoiceNum { get; set; }

public string InvoiceSecondaryNum { get; set; }

public string CustomerName { get; set; }

public decimal? CompetenceAmount { get; set; }
}
}

//CONTROLLER

public void ExportToExcel(string GridModel)

{

ExcelExport exp = new ExcelExport();

GridProperties obj = (GridProperties)Syncfusion.JavaScript.Utils.DeserializeToModel(typeof(GridProperties),GridModel);

exp.Export(obj, (IEnumerable)(obj.DataSource),"ExportCompetenze.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron");//EXCEPTION!!!!

}

When I try to export by clicking on one of the buttons in the toolbar, I receive the following error:

System.ArgumentException
HResult=0x80070057
Messaggio='CompetenceYear' non è un membro del tipo 'System.Collections.Generic.KeyValuePair`2[System.String,System.Object]'
Origine=
Analisi dello stack:

I'm using version16.4460.0.42

Can you help me?

Thanks

Padmavathy Kamalanathan [Syncfusion]
Replied On August 19, 2019 05:23 PM UTC

Hi Claudio, 

Thanks for contacting Syncfusion Forum. 

QUERY: Error while exporting Grid 
 
From your query we understand that you have issue with dataSource passed to the export method while exporting grid. The dataSource you have passed as a parameter to export method is taken from grid model property ( obj.DataSource in your code).  We suggest you to pass data to export parameter like in the below code, 

 
 public void ExportToExcel(string GridModel) 
  { 
    ExcelExport exp = new ExcelExport(); 
 
    var DataSource = order; 
 
    GridProperties obj = (GridProperties)Syncfusion.JavaScript.Utils.DeserializeToModel(typeof(GridProperties), GridModel); 
 
     exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron"); 
        } 


Please refer the below help documentations, 

Still facing the issue, we suggest you to share us the below details, 
  1. the dataSource model of grid (if possible)
  2. data passed to that particular “Competence Year”
If you have further queries, please get back to us. 
Regards, 
Padmavathy Kamalanathan 


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