Skip to content

Instantly share code, notes, and snippets.

@corespider
Last active June 29, 2020 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corespider/1bc086a6f07a52806442940ea9f438ed to your computer and use it in GitHub Desktop.
Save corespider/1bc086a6f07a52806442940ea9f438ed to your computer and use it in GitHub Desktop.
CoreSpider- Export to Excel in ASP .NET MVC
@model IEnumerable<ExportExcel_ASPNETMVC.Models.Customer>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
@using (Html.BeginForm("Export", "Customer", FormMethod.Post))
{
<div class="container">
<input type="submit" value="Export to Excel" class="btn btn-primary" />
</div>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.CustomerName)
</th>
<th>
@Html.DisplayNameFor(model => model.CustomerAddress)
</th>
<th>
@Html.DisplayNameFor(model => model.CustomerMobile)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.CustomerName)
</td>
<td>
@Html.DisplayFor(modelItem => item.CustomerAddress)
</td>
<td>
@Html.DisplayFor(modelItem => item.CustomerMobile)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.CustomerId }) |
@Html.ActionLink("Details", "Details", new { id = item.CustomerId }) |
@Html.ActionLink("Delete", "Delete", new { id = item.CustomerId })
</td>
</tr>
}
</table>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment