- Home
- Forum
- ASP.NET MVC
- Error while exporting grid
Error while exporting grid
Hi.
.Datasource(ds => ds.Json((IEnumerable<SlimHub.ViewModels.InvoiceCompetenceVM>)Model)) 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); 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(); eve.RecordDoubleClick("onInvoiceRecordDoubleClick");
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!!!!
Messaggio='CompetenceYear' non è un membro del tipo 'System.Collections.Generic.KeyValuePair`2[System.String,System.Object]'
I have the following grid:
@(Html.EJ().Grid<SlimHub.ViewModels.InvoiceCompetenceVM>
("InvoicesGrid")
.AllowMultiSorting()
.AllowFiltering()
.AllowSelection()
.AllowSorting()
.AllowGrouping()
.EnableHeaderHover()
.AllowResizing()
.AllowTextWrap(true)
.Locale("it-IT")
.GroupSettings(x => x.GroupedColumns(xf => { xf.Add("CompetenceYear"); }))
.ShowSummary()
.SummaryRow(row =>
{
})
{
}))
.Columns(col =>
{
})
.ClientSideEvents(eve =>
{
})
)
//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();
}
When I try to export by clicking on one of the buttons in the toolbar, I receive the following error:
System.ArgumentException
HResult=0x80070057
Origine=
Analisi dello stack:
I'm using version16.4460.0.42
Can you help me?
Thanks
SIGN IN To post a reply.
1 Reply
PK
Padmavathy Kamalanathan
Syncfusion Team
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,
- the dataSource model of grid (if possible)
- data passed to that particular “Competence Year”
If you have further queries, please get back to us.
Regards,
Padmavathy Kamalanathan
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
CR CLAUDIO RICCARDI
- Aug 17, 2019 05:59 AM UTC
- Aug 19, 2019 05:23 PM UTC