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
Abhimanyu Singh
NA
116
49k
How to Export the data From Database into Excel sheet ?????
Jun 5 2013 2:34 AM
Hii Every One here,
I am Abhimanyu Singh.. as i new in this field..i need help of you all.
Please help me to fetch/export the all Data of Data Base into excel sheet..
Actually i tried it with the help of Grid View Display but still its displaying only one/first page (visited page in grid) data.
And the big problem is that we do not want to display the Grid in designing page so I hide it(only taken a image button named "Export to Excel").
so please tell me is there any alternate way for
Exporting the All pages data into excel without any navigation in next page because as told it is hidden in designing page only i want on button click event.
Or you can tell me other way to do this
Code mentioned below:
protected void ImageButton5_Click(object sender, ImageClickEventArgs e)
{
con.Open();
SqlDataAdapter da3 = new SqlDataAdapter("Select applicant_id as 'Unique_ID', applicant_name as 'Name', father_name as 'Father Name', dob as 'Date of Birth', postal_address as 'Postal Address', pin as 'Pin', contact_no as 'Contact NO.', gender as 'Sex', marital as 'Marital', edu_quali as 'Qualification', email_id as 'Email ID', business_occupation as 'Occupation', experienced_fresher as 'Experience', audition_state as 'Audition State', audition_center as 'Center/ District', dd_cheq_no as 'Cheque No.', dd_cheq_date as 'Cheque Date', dd_cheq_amt as 'Cheque Amount', dd_cheq_bank as 'Bank', entry_date as 'Applied Date', form_place as 'Applied Place' from applicant_record", con);
DataSet ds3 = new DataSet();
da3.Fill(ds3);
DataTable dt3 = ds3.Tables[0];
GridView1.DataSource = dt3;
GridView1.DataBind();
con.Close();
// For Exporting into Excel sheet...........
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=FileName.xls");
Response.Charset = "";
// If you want the option to "open only" the Excel file without "saving option"--then comment out the line below
//Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
// Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.
}
Reply
Answers (
2
)
--RESOLVED-- How to dispose a GifEncoder ?
Crystal report show the blank page in c#.net