export model data to excel mvc

前端 未结 1 831
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-15 18:17
@model SA.MarketingManager.WebClient.Areas.Reports.Models.ViewReportModel
@{
    Layout = \"~/CustomViews/lennoxcap.net/Shared/_DealerLayout.cshtml\";
}
@using (Html         


        
1条回答
  •  星月不相逢
    2021-01-15 19:14

    I wrote a little blog post about this here : http://landokal.wordpress.com/2011/04/28/asp-net-mvc-export-to-excel-trick/

    Essentially, what you could do is, create a button that sent the contents of one of the elements on your page and assigned it to a property on your model, therefore everytime you exported that view, your Export method could check the model property instead of rendering the view directly.

    Also in the post are some code samples how to do a basic export to excel in MVC if you don't want to go the other route.

    0 讨论(0)
提交回复
热议问题