@(Html.EJ().Grid<object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.dataSource)
.AllowPaging()
.ToolbarSettings(toolBar => toolBar.ShowToolbar(true).ToolbarItems(items =>
{
items.AddTool(ToolBarItems.ExcelExport);
}))
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").Add();
col.Field("CustomerID").HeaderText("Customer ID").Add();
col.Field("EmployeeID").HeaderText("Employee ID").Add();
col.Field("Verified").HeaderText("Verified").Add();
col.Field("ShipName").HeaderText("ShipName").Add();
})
)
public void ExportToExcel(string GridModel)
{
ExcelExport exp = new ExcelExport();
GridProperties obj = ConvertGridObject(GridModel);
var DataSource = OrderRepository.GetAllRecords().ToList();
obj.ServerExcelQueryCellInfo = queryCellInfo;
exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false"flat-saffron");
}
public void queryCellInfo(object currentCell) {
IRange range = (IRange)currentCell;
if (range.Column == 4 && range.Value == "TRUE")
range.Value = "YES";//assign the value for the Checked value
else if(range.Column == 4 && range.Value == "FALSE")
range.Value = "NO";// assign the value for the Unchecked value
}
|