BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
var testObj = new List<dynamic>() { new { Forename = "Forename", Surname = "surname" }, new { Forename = "Forename1", Surname = "surname1" } }; exp.Export(obj, testObj, "Export.xlsx", ExcelVersion.Excel2016, false, false, "flat-saffron");
@(Html.EJ().Grid<object>("DataTableGrid") .Datasource((DataTable)ViewBag.dataTable) .AllowPaging() .ToolbarSettings(toolBar => toolBar.ShowToolbar().ToolbarItems(items => { items.AddTool(ToolBarItems.ExcelExport); items.AddTool(ToolBarItems.WordExport); })) .Columns(col => { ------------------------ }) ) ----------------------------------------------- public void ExportToExcel(string GridModel) { ExcelExport exp = new ExcelExport(); GetGridDT(); var DataSource = _dTable; GridProperties obj = ConvertGridObject(GridModel); exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron"); } |
Queries | Response |
“Can you recompile the project in 14.3.0.49 version.” | Yes, we recompile the project in 14.3.0.49 version and download the project from the below link Sample Link : https://www.syncfusion.com/downloads/support/forum/127182/ze/MvcApplication16-2061345506 |
“Exception details” | We checked your screenshot and mentioned exception will occurred when the columns bound to the Grid are not defined in the Grid dataSource, and are passed to the exporting method in Code behind. For more information, refer the below knowledgebase documentation If you still face the same issue, please reproduced the issue in the attached sample and sent back to us. |
foreach (var item in Model.EnglishSubjects) { col.Field(item.SubjectID + ".Display").HeaderText(Model.Table.Columns[item.SubjectID.ToString()].Caption).HeaderTooltip(item.SubjectName).Add(); }
Queries | Response | |
“Null Exception” | According to your code example, we found that you have used ForeignKey column in the grid. So, to avoid the mentioned issue please refer the below documentation. | |
“i want the colours of the cells to be exported” | To customize the style for the exported grid, use the AutoFormat class. With the autoFormat class, you can provide required color to the grid content, row background or border color. Find the code example and sample:
For more information refer the below document. You can customize the particular cell or particular row of exporting files using server events. For more information, refer the below document. |
foreach (var item in Model.EnglishSubjects) { col.Field(item.SubjectID + ".Display").HeaderText(Model.Table.Columns[item.SubjectID.ToString()].Caption).HeaderTooltip(item.SubjectName).Add(); }
@(Html.EJ().Grid<MvcApplication14.OrdersView>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.dataSource) .AllowPaging() .ToolbarSettings(toolBar => toolBar.ShowToolbar().ToolbarItems(items => { items.AddTool(ToolBarItems.ExcelExport); items.AddTool(ToolBarItems.WordExport); items.AddTool(ToolBarItems.PdfExport); })) .Columns(col => { col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Visible(false).Width(75).Add(); col.Field("Name.NameNew").HeaderText("Name").Width(80).ValidationRules(v => v.AddRule("required", true).AddRule("minlength", 3)).Add(); ----------------- }) ) |
@(Html.EJ().Grid<MvcApplication14.OrdersView>("FlatGrid") .Datasource((DataTable)ViewBag.dataTable) .EnableAltRow(false) .---------------------- .ShowStackedHeader() .StackedHeaderRows(row => { ----------------------------------- }) .AllowPaging(true) .PageSettings(p => p.PageCount(5).PageSize(10)) .IsResponsive(true) .EnableResponsiveRow(true) .FilterSettings(filter => { filter.FilterType(FilterType.Menu); }) .AllowTextWrap() .TextWrapSettings(wrap => { wrap.WrapMode(WrapMode.Both); }) .ShowColumnChooser() .AllowScrolling() .ScrollSettings(col => { col.Height("auto").Width("100%"); }) .MinWidth(1250) .Columns(col => { ------------------------------- }) ) |
Hi Indrani,We can reproduce the mentioned issue in the attached sample. The mentioned issue is reproduced due to the complex data in datatable. We considered this requirement as an improvement and a support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.
Regards,Prasanna Kumar N.S.V