Export to excel from datagrid

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:

  1. Calculated values obtained by this method
  2. 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 :slight_smile:

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.

  1. Your datasource should be iqueryable .i.e extend your datamodel
  2. extend the exportcontroller and add your custom path
        public FileStreamResult ExportGrid(string fileName = "ExportGrid")
            var items = GetYourDataSource.AsQueryable();
             return ToExcel(queryview, fileName);
  1. 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?

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.