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
136.3k
export data into excel in mvc 5
Jun 23 2015 12:34 PM
Hi,
I need to export webgrid data into excel, I am using mvc 5 application. one button in view called Export, click that button, webgrid data into export into excel file. webgrid generated dynamic data, dont know how many columns or rows.
here is my controller code.
public ActionResult RunReports(int? id)
{
DomainContext CurrentLoginUser = ActiveDirectory_AccessModel.GetUserDetails(); // Username
var userDetails = (from c in db.SP_GR_Get_Userdetails(CurrentLoginUser.DisplayName)
select c.user_roles).FirstOrDefault();
if (userDetails == null)
{
return RedirectToAction("NoAccess");
}
var runResult = (from c in db.tbl_GR_Reports
where c.Report_ID == id
select c).SingleOrDefault();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
if (runResult != null)
{
Microsoft.Practices.EnterpriseLibrary.Data.Database salesworldDbConn = new SqlDatabase(runResult.Db_Connection);
DbCommand cmd = salesworldDbConn.GetSqlStringCommand(runResult.Query);
try
{
ds = salesworldDbConn.ExecuteDataSet(cmd);
}
finally
{
cmd.Dispose();
salesworldDbConn = null;
}
if (ds != null && ds.Tables.Count > 0)
{
dt = ds.Tables[0];
}
}
return View(dt);
}
Reply
Answers (
1
)
Microsoft.ace.oledb.12.0 drivers
How to not show on Label when change dropdownlist if duplica