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
Hardik Patel
NA
378
469.5k
how to export data in excel 2007 in asp.net c#?
Sep 4 2013 6:46 AM
i am using below code but it's not working properly for MS Excel 2007..
DataTable dt = new DataTable();
string str1;
str1 = "SELECT Testt1.StudentCode, Student.StudentID,Student.Name, Testt1.FMark,'' as 'LMark','' as'Status',''as 'Promote' FROM Testt1 INNER JOIN School ON Testt1.SchoolCode = School.SchoolCode INNER JOIN Student ON Testt1.StudentCode = Student.StudentCode where Testt1.Promote ='Yes' and School.SchoolCode =" + DropDownList3.SelectedValue + "";
dt = ObjConn.GetDataTable(str1);
HttpResponse response = HttpContext.Current.Response;
response.Clear();
//response.Charset = "";
response.ContentType = "application/vnd.ms-excel";
response.AddHeader("Content-Disposition", "attachment;filename=Smarks.xls");
//response.AddHeader("Content-Disposition", "C:\"" + fileName + "\"");
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
DataGrid dg = new DataGrid();
dg.DataSource = dt;
dg.DataBind();
dg.RenderControl(htw);
response.Write(sw.ToString());
response.End();
Reply
Answers (
1
)
read outlook email
How to connect a dekstiop apps with online database?