Model view controller 将基础设施网格数据导出到excel

Model view controller 将基础设施网格数据导出到excel,model-view-controller,infragistics,Model View Controller,Infragistics,我需要将数据从infragistics网格导出到excel,我们也在使用mvc。我得到了代码,但它的作用是循环遍历每个记录,然后形成excel,这会导致性能不佳。但我想要的是,它应该像我们在asp.net中做的那样,立即绑定网格数据 我浏览了很多网站,包括基础设施网站,但到处都是相同的代码。有没有办法做到这一点 下面是我现在使用的代码 int i = 1; foreach (Market item in collection) {

我需要将数据从infragistics网格导出到excel,我们也在使用mvc。我得到了代码,但它的作用是循环遍历每个记录,然后形成excel,这会导致性能不佳。但我想要的是,它应该像我们在asp.net中做的那样,立即绑定网格数据

我浏览了很多网站,包括基础设施网站,但到处都是相同的代码。有没有办法做到这一点

下面是我现在使用的代码

        int i = 1;
        foreach (Market item in collection)
        {
            currentWorksheet.Rows[i].Cells[0].Value = item.gp_name;
            currentWorksheet.Rows[i].Cells[1].Value = item.gp_MarketCode;
            currentWorksheet.Rows[i].Cells[2].Value = item.gp_CountryName;
            currentWorksheet.Rows[i].Cells[3].Value = item.gp_ISOCode;
            currentWorksheet.Rows[i].Cells[4].Value = item.gp_EricssonOperationalModelEOM;
            currentWorksheet.Rows[i].Cells[5].Value = item.gp_region_name;
            i++;


        }

        Response.Clear();
        Response.AppendHeader("content-disposition", "attachement; filename=Market.xlsx");
        Response.ContentType = "application/octet-stream";
        currentWorkbook.SetCurrentFormat(WorkbookFormat.Excel97To2003);
        currentWorkbook.Save(Response.OutputStream); 
        Response.Flush();
        Response.End();
        //return RedirectToAction("Index");
    }

您是否尝试过使用DataPresenterXcelExporter

DataPresenterExcelExporter  exporter = new DataPresenterExcelExporter ();
exporter.Export(Grid, FileName, WorkbookFormat.Excel2007, Exportoptions);

不,我没有,但如果您能给我发送一些示例链接,那么我可以尝试。谢谢,请参考以下链接: