Hi guys, does anybody have an example for exporting datagrid to an excel but this datagrid has a calculated values, so it is not from datasource or can you tell me an external component that could be stable.
I could export successfully from radzengrid with calculated values from below methods:
- Calculated values obtained by this method
- extend the exportcontroller and convert
public FileStreamResult ExportTicketGroupsToExcel(string fileName = null)
{
var items = clique.GetTicketGroups().Result.ToList().Where(o=>o.Balance>0 && o.Status=="A" && o.CustomerID!=1).AsQueryable();
var queryview= ApplySelectQuery(items,Request.Query);
return ToExcel(queryview, fileName);
}
Hope this helps
Thanks @Vinod_Pillai , I will try to do that.
Hi @Vinod_Pillai , What files do you had to extend for exporting a datagrid to an excel, i have a data grid with calculate values columns and it's not from a datasource because i created with custom values. Im Lost and i dont know where do i have to modify to export my datagrid or any grid.
- Your datasource should be iqueryable .i.e extend your datamodel
- extend the exportcontroller and add your custom path
[HttpGet("/export/YourProject/ExportGrid")]
public FileStreamResult ExportGrid(string fileName = "ExportGrid")
{
var items = GetYourDataSource.AsQueryable();
return ToExcel(queryview, fileName);
}
- Invoke this in your export button click event
UriHelper.NavigateTo($"export/YourProject/ExportGrid()", true);
Thanks @Vinod_Pillai I Think I'm too close to get it, The exportController must be in the radzen ignore list to extend it?
Hi,
You may extend exportcontroller using partial class
public partial class ExportYourProjectController : ExportController
Hi, I read last message too late but I already did it during last day, thanks for your help.