TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
neel k
NA
143
137k
MVC 5 EXPORT TO EXCEL not working in IE
Aug 11 2015 12:39 PM
Hi
I am trying to export table to excel below is my code, its working in chrome but not in IE. I am using MVC 5
Controller code:
public ActionResult Index()
{
return View(db.tbl_GR_Reports.ToList());
}
public ActionResult ExportData()
{
GridView gv = new GridView();
gv.DataSource = db.tbl_GR_Reports.ToList();
gv.DataBind();
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename=list.xls");
Response.ContentType = "application/ms-excel";
Response.Charset = "";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gv.RenderControl(htw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
return RedirectToAction("tbl_GR_Reports");
}
View Code:
@model IEnumerable<ExporttoExcel.Models.tbl_GR_Reports>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table style="border: 1px solid black;border-collapse:collapse;" width="900" align="center">
<tr>
<th>
@Html.DisplayNameFor(model => model.Report_Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
<th>
@Html.DisplayNameFor(model => model.Query)
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td width="10%" style="border-bottom:1px solid black; border-right:1px solid black">
@Html.DisplayFor(modelItem => item.Report_Name)
</td>
<td width="10%" style="border-bottom:1px solid black; border-right:1px solid black">
@Html.DisplayFor(modelItem => item.Description)
</td>
<td width="40%" style="border-bottom:1px solid black; border-right:1px solid black">
@Html.DisplayFor(modelItem => item.Query)
</td>
</tr>
}
</table>
@using (Html.BeginForm("ExportData", "tbl_GR_Reports", FormMethod.Post))
{
<table>
<tr><td></td><td><input type="submit" name="Export" id="Export" value="Export" /></td></tr>
</table>
}
Thanks,
Reply
Answers (
0
)
Is there any chance to put dotnet existing project in cloud
Autocomplete jquery grid itemtemplate tabmenu