I have a generated a view for a particular search type ( agency -name Abc Enterprise) having the following details and a webgrid(as per search)
Name of the Institute: ABC ENTERPRISE
Total No. of Feedback submitted: 5
Incountry Feedback: 5
Overseas Feedback: 0
Overall Score of the Institute: 3.3
Now i have to download in excel the above mentioned details along with the programme title the agency has conducted( title details has been saved in table)
So how to download this information in excel on click in view.
What I have tried:
MVC CONTROLLER FOR SEARCH
[Authorize]
[HttpGet]
public ActionResult TrainingInstitute(String agenda_no = "")
{
DisplayLndRep dn = new DisplayLndRep();
DbAccess da = new DbAccess();
LndFeedbackReport.Models.LoginViewModel uinfo = new LndFeedbackReport.Models.LoginViewModel();
uinfo = da.FindUserInfoAD(User.Identity.Name);
dn.FullName = uinfo.FullName;
dn.FeedbackDetailList5=new List<lnd_prgm>();
dn.Cre_name = agenda_no;
dn.FeedbackDetailList5 = da.FindInstiStdCount(agenda_no);
dn.app_count = dn.FeedbackDetailList5.Count;
if(dn.app_count>0)
{
dn.ListArcGrid = new List<ReportLndFeedback>();
dn.FeedbackDetailList4 = da.FindInstiPgmTypCount(agenda_no);
dn.pg1_count = dn.FeedbackDetailList4.Count();
dn.pg2_count = dn.app_count - dn.pg1_count;
dn.score = da.FindTotalScore(agenda_no);
dn.instiname = agenda_no.ToUpper();
if(dn.score != null)
{
ViewBag.Total = (float)dn.score.Sum(x => x.pgm_avg);
}
dn.marks = ViewBag.Total/dn.score.Count();
dn.PageSize = 10;
}
else
{
TempData["notice"] = "There is no such record for Training Institute." + agenda_no;
return RedirectToAction("ReportModule", "Home");
}
return View(dn);
}
view Code
@model LndFeedbackReport.ViewModels.DisplayLndRep
@{
ViewBag.Title = "Reports";
}
@*<br /><br />*@
@*<div class="pull-right">
<a class="btn btn-info" href="@Url.Action("MainForm", "Home")">Back</a>
<a class="btn btn-info" href="@Url.Content("~/Account/LogOff/")">LogOff</a>
</div>*@
@*<br /><br /><br />*@
<div class="row">
<div class="panel panel-success" style="padding-top: 0px;">
<div class="panel-heading">
<span style="color:blue">Welcome</span> <span style="color:black">User : </span><span style="color:red">@Model.FullName</span> <span style="color:black">Salary Code : </span><span style="color:red">@Model.EmployeeId</span> <span style="color:black">Designation : </span><span style="color:red">@Model.Designation</span> <span style="color:black">Department : </span><span style="color:red"> @Model.DepartmentName </span>
</div>
</div>
</div>
<h3>Report Layout</h3>
<div class="row col-md-12">
<div class="panel panel-body panel-danger">
<br>Name of the Institute:<span style="color:blue;font-weight:bold"> @Model.instiname</span><br />
<br>Total No. of Feedback submitted:<span style="color:blue;font-weight:bold"> @Model.app_count</span><br />
<br>Incountry Feedback:<span style="color:blue;font-weight:bold"> @Model.pg1_count</span><br />
<br>Overseas Feedback:<span style="color:blue;font-weight:bold"> @Model.pg2_count</span><br />
<br>Overall Score of the Institute:<span style="color:blue;font-weight:bold"> @Model.marks</span><br />
@*<br>Total No. of applications evaluated:<span style="color:blue;font-weight:bold"> @Model.evaluated_reports</span><br />
<br>Total No. of applications not evaluated:<span style="color:blue;font-weight:bold"> @Model.not_evaluated_reports</span><br />*@
</div>
</div>
<div class="wrap">
<div class="content">
@Html.AntiForgeryToken()
<div class="inner-content" style="border:none">
<span class="text-primary" style="color:crimson; font-size:larger">List of Feedback Submitted</span>
<span> <a class="btn btn-info" title="Report Module" href="@Url.Action("ReportModule", "Home")">Report Module</a></span>
</div>
</div>
</div>
<br />
@{
WebGrid grid = new WebGrid(null, rowsPerPage: @Model.PageSize, canPage: true);
grid.Bind(Model.FeedbackDetailList4, autoSortAndPage: true, rowCount: @Model.PageSize);
grid.Pager(WebGridPagerModes.NextPrevious);
}
<div>
@grid.GetHtml(tableStyle: "table table-bordered table-striped", headerStyle: "bg-success", selectedRowStyle: "bg-warning", footerStyle: "bg-warning",
mode: WebGridPagerModes.All,
firstText: "<< First",
previousText: "< Prev",
nextText: "Next >",
lastText: "Last >>",
columns: grid.Columns(
grid.Column("prgm_id", "Feedback ID", format: @<text><div style="text-align: center"><a title="View" href="@Url.Action("ShowProgramDetails", "Home", new { ac = item.prgm_id })">@item.prgm_id</a></div></text>),
grid.Column("prgm_type", "Feedback Type"),
grid.Column("Create_by", "Submitted By"),
grid.Column("from_date", "From Date", format: (item) => (item.from_date == null) ? "" : string.Format("{0:dd-MM-yyyy}", item.from_date)),
grid.Column("till_date", "Till Date", format: (item) => (item.till_date == null) ? "" : string.Format("{0:dd-MM-yyyy}", item.till_date)),
grid.Column("pgm_avg", "Score"),
grid.Column("fdk_remarks", "Remarks")
@*grid.Column(header: "VIEW", format: @<text><a class="btn btn-default" title="View" href="@Url.Action("ShowProgramDetails", "Home", new { ac = item.prgm_id})"><img src="@Url.Content("~/Content/Images/View1.png")" width="20" height="20" alt="View" /></a></text>)*@
))
</div>
<div class="wrap">
<div class="content">
@Html.AntiForgeryToken()
<div class="inner-content" style="border:none" align="left">
@using (Ajax.BeginForm("DownloadTrainRep", "Home",new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "result" }))
{
<span><button type="submit" class="btn btn-info">Download</button></span>
}
</div>
</div>
</div>